我正在关注this tutorial,只是我改变了与UCanAccess的连接。
我导入了所有的罐子,但我仍然收到错误,我不知道是什么问题
错误
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.6 invalid page number 1
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:264)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at servlets.ConnectionManager.getConnection(ConnectionManager.java:22)
at servlets.UserDAO.login(UserDAO.java:35)
at servlets.LoginServlet.doGet(LoginServlet.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
代码
package servlets;
import java.sql.*;
public class ConnectionManager {
static Connection conn;
static String url;
public static Connection getConnection()
{
try
{
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String url="jdbc:ucanaccess://C:/workspaceWeb/LoginExample/src/servlets/usersetup.db";
System.out.println("blabla");
conn = DriverManager.getConnection(url,"UserName", "PassWord");
System.out.println("commecla");
}
catch (SQLException | ClassNotFoundException ex)
{
ex.printStackTrace();
}
return conn;
}
}
答案 0 :(得分:1)
您正尝试使用UCanAccess打开SQLite数据库,但这不会起作用。 UCanAccess只能打开Access数据库(.accdb,.mdb或相关)。要使用SQLite数据库,您需要使用类似Xerial' SQLite JDBC Driver的内容。