1
votes

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);
            }
        }
    }
2
Are you getting an error/Exception? Is the SQL succeeding but the table is still there?Adam Batkin
@Adam Batkin: I am not getting any exceptions, the SQL seems to be succeeding but table is still there..user775187
Do you have rows in the DUAL table?Piyush Mattoo

2 Answers

0
votes

Try committing after executing the DDL.

1
votes

It turns out I need to do an explicit shutdown aftwards

 DBManager.executeUpdate("shutdown");