【发布时间】:2021-02-04 22:24:38
【问题描述】:
在JDBC Tutorial 中有几个可以运行的示例java 程序。 Ant 目标 runcrs 不运行。当我在嵌入式驱动程序模式下使用 Derby 提供的代码时,crs.execute 出现错误:
try {
crs.setUsername(settings.userName);
crs.setPassword(settings.password);
crs.setUrl(settings.urlString);
crs.setCommand("select * from MERCH_INVENTORY");
// Setting the page size to 4, such that we
// get the data in chunks of 4 rows @ a time.
crs.setPageSize(100);
// Now get the first set of data
crs.execute(); // Throws exception. No suitable driver found.
[java] Found item 6914: Cookbook (12) [java] Found item 123456: TableCloth (14) [java] java.sql.SQLException: No suitable driver found for jdbc:derby:testdb [java] at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702) [java] at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228) [java] at java.sql.rowset/com.sun.rowset.internal.CachedRowSetReader.connect(CachedRowSetReader.java:340) [java] at java.sql.rowset/com.sun.rowset.internal.CachedRowSetReader.readData(CachedRowSetReader.java:157) [java] at java.sql.rowset/com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:809) [java] at java.sql.rowset/com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:1435) [java] at com.oracle.tutorial.jdbc.CachedRowSetSample.testPaging(CachedRowSetSample.java:98) [java] at com.oracle.tutorial.jdbc.CachedRowSetSample.main(CachedRowSetSample.java:254) [java] SQLState: 08001 [java] Error Code: 0 [java] Message: No suitable driver found for jdbc:derby:testdb
在放弃并寻求解决方案之前,我查看了以下帖子。它们涵盖了非嵌入式(客户端-服务器)实现,它们没有涵盖 CachedRowSet 接口。通常,解决方案是检查 derby.jar 是否在类路径中。 (我检查了——没有运气。此外,驱动程序显然正在加载,因为非 RowSet 功能正在工作,例如,找到项目 123456。)
The infamous java.sql.SQLException: No suitable driver found - 涵盖了 derby 的客户端/服务器实现
SQLException: No suitable driver found for jdbc:derby://localhost:1527 - 客户端-服务器,未嵌入
no suitable driver found error for JDBC DERBY - 不是 RowSet 实例化
No suitable driver found for jdbc:derby://localhost:1527/prosto - 客户端/服务器,未嵌入
http://apache-database.10148.n7.nabble.com/No-suitable-driver-found-for-jdbc-derby-td108280.html - 使用Class.forName;没有行集
JDBC embedded Derby: No suitable driver found - 根本原因:连接字符串语法错误
java.sql.SQLException: No suitable driver found for jdbc:derby: - 根本原因:类路径
【问题讨论】:
-
您遇到了什么异常?确保包含所有关于你得到的实际异常的信息,这将有助于人们给你最好的建议。这里还有更多内容:cwiki.apache.org/confluence/display/DERBY/UnwindExceptionChain
-
好点。我几乎害怕因为重复的帖子标签的机会。无论如何,我会添加它。