在此代码中,我试图删除表,如果它们在每次运行该程序时都已存在,但控件不在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(" +.....