次のコードがあります。
Connection conn = null;
Statement stmt = null;
// MySQL connection details.
String username = ("username");
String password = ("password");
String url = ("jdbc:derby://localhost:1527/OnlineLibrary");
try {
// Connect to database.
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
conn = DriverManager.getConnection (url, username, password);
stmt = conn.createStatement();
// Get data.
String query = ("SELECT PersonNo, Forename, Surname FROM Person;");
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
System.out.println("Person: no: " + rs.getInt("PersonNo") + " name: " + rs.getString("Forename") + " " + rs.getString("Surname"));
}
// Disconnect from database.
stmt.close();
conn.close();
}
catch(Exception ex) {
Java_Utils.printStackTrace("Error connecting to database", ex, true);
}
それは私に与えます:
Error connecting to database
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
org.apache.derby.client.am.Statement.executeQuery(Unknown Source)
misc.Simple_JDBC_Test.main(Simple_JDBC_Test.java:32)
私にはすべてが順調に思えます。接続プールを使用して DB に接続できますが、上記のエラーがわかりません。