Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:file:Pokemondaten","sa","");
getData = conn.createStatement();
ResultSet rs = getData.executeQuery
("SELECT HP FROM PKMN WHERE ID = " + basicnumber);
int hpp = rs.getInt(1);
System.out.println(hpp);
我得到的只是
java.sql.SQLException: Table not found in statement [SELECT HP FROM PKMN]
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
at pokeWpRechner.Main.main(Main.java:46)
我的数据库名为Pokemondaten
,我的表名为PKMN
,我的表也在程序中继承。
那我做错了什么?我不明白。
答案 0 :(得分:1)
尝试以下
conn = DriverManager.getConnection("jdbc:hsqldb:file:Pokemondaten;shutdown=true","sa","")
这应该可以防止表定义丢失
答案 1 :(得分:0)
我认为您需要在JDBC URL中提供数据库文件的完整路径:
DriverManager.getConnection("jdbc:hsqldb:file:c:\mydir\Pokemondaten","sa","");