我这里有访问 mySQL 数据库的 java 代码。它检查表是否存在。该表已删除且不存在,但下面的代码表明该表存在。
private Boolean tableExists(String globalId) {
// schema Test
DBResult result = db.selectQuery("SELECT table_name
FROM information_schema.tables
WHERE table_schema = '"+schema+"'
AND table_name = " + "\'" + "category_"+globalId.split("-")[1]+ "\'"+";");
if(result.getRowCount() > 0) {
logger.info(" Table exist "+globalId);
return true;
} else {
logger.info("table does not exist "+ globalId);
return false;
}
}
该方法返回真表存在。后来,程序发现该表不存在并崩溃。请问是什么问题?该程序在 Tomcat 6 上运行。
最佳答案
重新启动 MySQL
。 (必要时终止进程)。这应该有效。
MySQL
中存在同步问题。
关于java - 检查 MySQL RDMS 上是否存在表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6132304/