I am unable to drop table with default user SA(or any user for that matter) in HSQLDB even though I can create table and read them without problem, please see my code below, what's wrong? On the other hand, If I use a third party SQL client(eg. squirrel), I can login and drop table without problem even when user is empty.
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); } } }
It turns out I need to do an explicit shutdown aftwards
DBManager.executeUpdate("shutdown");
Try committing after executing the DDL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.