我无法在HSQLDB中使用默认用户SA(或任何用户)删除表,即使我可以创建表并且没有问题地阅读它们,请参阅下面的代码,出了什么问题?另一方面,如果我使用第三方SQL客户端(例如squirrel),即使用户为空,我也可以毫无问题地登录和删除表 .
public static void main(String[]args){
try {
DBManager.executeUpdate("drop table mytable");
} catch (SQLException ex) {
ex.printStackTrace();
}
}
public static Connection getConnection(){
Connection c =null;
try {
c = DriverManager.getConnection("jdbc:hsqldb:file:e:\\xxx_db\\xxx", "SA", "");
} catch (SQLException ex) {
ex.printStackTrace();
}
return c;
}
public static int executeUpdate(String s) throws SQLException {
Connection con = getConnection();
try{
return con.createStatement().executeUpdate(s);
}
finally{
if(con!=null)try {
con.close();
} catch (SQLException ex) {
Logger.getLogger(DBManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
2 回答
事实证明我需要做一个明确的关机
尝试执行DDL后提交 .