In the JDBC Tutorial there are several example java programs that can be run. Ant target runcrs does not run. When I use the code as provided using Derby in embedded driver mode, I get an error on 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
I looked at the following posts prior to giving up and seeking a solution. They covered non-embedded (client-server) implementations, they were not covering the CachedRowSet interface. Frequently the solution was to check to see if derby.jar was on the class path. (I checked -- no luck. Also, the driver was obviously loading because the non RowSet functionality was working e.g., Found item 123456.)
The infamous java.sql.SQLException: No suitable driver found - covered client/server implementations of derby
SQLException: No suitable driver found for jdbc:derby://localhost:1527 - client-server, not embedded
no suitable driver found error for JDBC DERBY - not a RowSet instantiation
No suitable driver found for jdbc:derby://localhost:1527/prosto - client/server, not embedded
http://apache-database.10148.n7.nabble.com/No-suitable-driver-found-for-jdbc-derby-td108280.html - uses Class.forName
; no RowSet
JDBC embedded Derby: No suitable driver found - root cause: syntax error on connect string
java.sql.SQLException: No suitable driver found for jdbc:derby: - root cause: class path