![](/img/trans.png)
[英]I am trying to create a table using java derby EmbeddedDriver but i don't understand what these errors mean?
[英]Can I use the Derby EmbeddedDriver with the CachedRowSet example specified in the Java tutorial?
在JDBC 教程中有幾個可以運行的示例 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 。)
臭名昭著的 java.sql.SQLException:找不到合適的驅動程序- 涵蓋了 derby 的客戶端/服務器實現
SQLException: 找不到適合 jdbc:derby://localhost:1527 的驅動程序- 客戶端-服務器,未嵌入
找不到適合 JDBC DERBY 的驅動程序錯誤- 不是 RowSet 實例化
找不到適合 jdbc 的驅動程序:derby://localhost:1527/prosto - 客戶端/服務器,未嵌入
http://apache-database.10148.n7.nabble.com/No-suitable-driver-found-for-jdbc-derby-td108280.html - 使用Class.forName
; 沒有行集
JDBC 嵌入式 Derby:找不到合適的驅動程序- 根本原因:連接字符串上的語法錯誤
事實證明,這些教程最近可能沒有使用 Derby 的 EmbeddedDriver 進行過測試。 通過將連接對象傳遞給不同的execute
方法重載,代碼無一例外地執行:
...
public CachedRowSetSample(Connection connArg,
JDBCTutorialUtilities settingsArg) {
super();
this.con = connArg;
...
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(con); // Executes without error // add 'con' (the connection object) as an arg
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.