在这段代码中,如果每次运行程序时表已经存在,我都会尝试删除它们,但控件不会进入if
语句内部。table1
并且table2
存在于数据库中。我已经在我的数据库中检查过了。由于它不在if
语句中,所以当我尝试创建表时,它在最后一行给出以下错误ORA-00955: name is already used by an existing object
:我究竟做错了什么?
Statement statement = connection.createStatement();
DatabaseMetaData md = connection.getMetaData();
String[] types = {"TABLE"};
ResultSet rs1 = md.getTables(null, null, "table1",types );
if (rs1.next()) {
System.out.println(rs1.getString(3));
statement.executeUpdate("drop table table1");
}
rs1.close();
ResultSet rs2 = md.getTables(null, null, "table2", types);
if (rs2.next()) {
statement.executeUpdate("drop table table2");
}
rs2.close();
statement.executeUpdate("create table table1(" +.....