I do not like the drop table with the Statement or PreparedStatement

0

I have this code to delete a table, in the same way, I have two more to insert data or delete them and they are barbarous, but this delete table is impossible, I do not know what happens, I used even with Statement and nothing.

      PreparedStatement pst;
            String borrarTablaSql= "drop table if exists empleados_?";
            pst= con.prepareStatement(borrarTablaSql);
            pst.setString(1, usuarioAdmin);
            pst.executeUpdate();
            pst.close();
    
asked by berlot83 18.03.2017 в 19:46
source

1 answer

1

Try using this code snippet:

PreparedStatement dropTable = cnx.prepareStatement(
String.format("DROP TABLE IF EXISTS %s", "features"));
dropTable.execute();
    
answered by 19.03.2017 / 00:55
source