簡體   English   中英

檢查 MySQL RDMS 上是否存在表

[英]Checking if table exists on MySQL RDMS

我這里有 java 代碼訪問 mySQL 數據庫。 它檢查表是否存在。 該表已被刪除並且不存在,盡管下面的代碼表示該表存在。

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;
  }
}

該方法返回 true 表示表存在。 稍后,程序捕獲到該表不存在並崩潰。 請問是什么問題? 該程序在 Tomcat 6 上運行。

重啟MySQL (必要時終止進程)。 那應該行得通。

MySQL中存在同步問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM