这个问题已经在这里有了答案 :
臭名昭著的java.sql.SQLException:未找到合适的驱动程序 (13个答案)
4年前关闭。
我有一个Java类,该类通过在Tomcat上运行的JSP中使用的JDBC通过JDBC访问MySQL数据库,并且遇到“未找到驱动程序异常”的问题。
我有一个方法:
private static Statement makeStatement() {
try{
com.mysql.jdbc.Driver d = null;
try{d = new com.mysql.jdbc.Driver();}catch(Exception e){
System.out.println("ERROR BY NEW DRIVER " + e.toString() +
"\n");e.printStackTrace();}
Connection con = DriverManager.getConnection(url, user, password);
return con.createStatement();
}catch(java.sql.SQLException ex){
System.out.println("ERROR IN makeStatement " + "\nERROR - " +
ex.toString() + "\n ERROR CODE:\n " + ex.getErrorCode() +
"\nSQLSTATE:\n " + ex.getSQLStat e());ex.printStackTrace();}
return null;
}
这会在“ Connection con = DriverManager.getConnection(url, user, password);
这是我从catalina.out的打印输出”上引发错误:
Received Parameters
ERROR IN makeStatement
ERROR - java.sql.SQLException: No suitable driver found for
ERROR CODE:
0
SQLSTATE:
08001
java.sql.SQLException: No suitable driver found for
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at message.Message.makeStatement(Message.java:72)
at message.Message.query(Message.java:79)
at message.Message.getName(Message.java:225)
at org.apache.jsp.message_jsp._jspService(message_jsp.java:288)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:548)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
ERROR IN QUERY java.lang.NullPointerException
ERROR in getName java.lang.NullPointerException
-----------------------------------
Received Parameters
newMessage =
newpassword =
verifypassword =
sendinfo =
username = Eli
newusername =
login = login
password = tree
ERROR IN makeStatement
ERROR - java.sql.SQLException: No suitable driver found for
ERROR CODE:
0
SQLSTATE:
08001
java.sql.SQLException: No suitable driver found for
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at message.Message.makeStatement(Message.java:72)
at message.Message.query(Message.java:79)
at message.Message.validUser(Message.java:195)
at org.apache.jsp.message_jsp._jspService(message_jsp.java:123)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:548)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
ERROR IN QUERY java.lang.NullPointerException
ERROR in validUser java.lang.NullPointerException
ERROR IN makeStatement
ERROR - java.sql.SQLException: No suitable driver found for
ERROR CODE:
0
SQLSTATE:
08001
java.sql.SQLException: No suitable driver found for
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at message.Message.makeStatement(Message.java:72)
at message.Message.query(Message.java:79)
at message.Message.getName(Message.java:225)
at org.apache.jsp.message_jsp._jspService(message_jsp.java:288)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:548)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
ERROR IN QUERY java.lang.NullPointerException
ERROR in getName java.lang.NullPointerException
唯一重要的错误是一个,makeStatement()
因为失败会导致所有其他错误。我已四重检查我的WEB-INF /
lib目录中是否具有正确的jar文件,并且重新启动Tomcat的次数比我想要的要多。我有一个makeStatement()
在不同的.java文件中使用的单独的webapp,该webapp运行良好。更奇怪的是,我在.java中有这个:
static {
System.err.println("\n\nTEST MYSQL ACCESS: dump all relevant tables:");
dump();
System.err.println("END OF MYSQL ACCESS ACCESS.");
}
public static void dump() {
try {
readUsers();
for (UserRecord u: users)
System.err.println(u.username+" "+u.password);
} catch (Exception e) {System.err.println(e);}
}
使用readUsers()
读取数据库中所有用户的位置makeStatement()
。这实际上可以正常工作,并且将打印数据库中的所有用户(出于明显的原因未在此处显示:)),然后发生驱动程序未找到错误。
我在一个类中有这段代码,用于连接数据库。 我得到这个错误: 我检查了用户名和密码,数据库服务的连接,一切都正确。
我有一个问题,Eclipse IDE不能识别. jar文件中的jdbc驱动程序。我已经尝试将它放在WEB-INF/Lib的构建路径和构建文件夹中。我已经在我的项目中添加了Class.forname来注册驱动程序。 这是我mysql数据库的url:“jbdc:mysql://localhost:3306/loginDB“。我使用的是Tomcat v9.0服务器。我使用的是5.1.49驱动程序版本的.
我继承了一个项目(而且我绝对没有Java的经验),我相当困窘。 我们有一个运行redhat的服务器,我需要它来更新一个jar文件。所以我简单地复制了更新的文件,并重新启动了该文件的服务。然而,这个过程已经在我们的另一台服务器上工作了,我也这样做了,但是在这个服务器上,它会在日志文件中出现下面的内容。 jar文件被上传到网站根目录下的一个文件夹中,该jar文件夹中有一个lib文件夹,其中包含mysq
问题内容: 我在Netbeans中收到此错误: 这是怎么引起的,我该如何解决? 问题答案: 找不到适合jdbc:derby:// localhost:1527 /的驱动程序 此异常有两个原因: 驱动程序未加载。 JDBC URL格式错误。 对于你的情况,我希望在连接字符串的末尾看到一个数据库名称。例如(create=true如果要创建不存在的数据库,请使用): 默认情况下,数据库是在启动网络服务器
问题内容: 我希望有一个人可以帮助我。我正在研究一个与SQLite数据库连接的简单应用程序。以下是我的连接代码: 这只是一个在数据库中加载用户名和密码的窗口。我的问题是,当我单击按钮时,出现以下异常: (我找到了一个有关如何使用Java连接到SQLite数据库的示例,我发现该示例运行良好) 这个程序我正在窗口构建器(日食)中做。我使用的示例中使用的驱动程序相同。我不知道我是否必须使用其他驱动程序。
我正在开发一个android应用程序,它从SQL Server导入lat/long以在地图中显示为标记。我已经输入了jtds-1.21。jar到lib的路径,但我得到了错误 这是我的代码图。Java语言