我正在尝试从使用SQL剪贴簿创建的Derby Apache数据库中获取数据。我为该方案创建了一个新方案和一个名为Testobject的新表,并将项目插入到该表中。如果在创建与数据库的连接后尝试执行查询,则会收到sql异常(42X05),该异常表示没有这样的表。有人可以帮忙吗?
public static void main(String[] args) {
try {
Connection c = DriverManager.getConnection("jdbc:derby:MediaPlayerDB;create=true", "", "");
request(c);
} catch(SQLException s) {
System.out.println("SQL: " + s.getMessage());
}
}
private static void request(Connection c) throws SQLException {
try {
Statement request = c.createStatement();
String query = "select * from Testobject";
ResultSet rs = query.executeQuery(befehl);
while(rs.next()) {
int i = rs.getInt("a");
String s = rs.getString("b");
float f = rs.getFloat("c");
System.out.println("ROW = " + i + " " + s + " " + f);
}
} catch(SQLException s) {
System.out.println("SQL: " + s.getMessage());
}