環境centos6.7,部署應用後啓動tomcat發現日誌報錯,如下:
Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't retrieve trigger: Table 'nntest.qrtz_TRIGGERS' doesn't exist [See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'nntest.qrtz_TRIGGERS' doesn't exist]
連接mysql查看qrtz_TRIGGERS存在;那麼則需要去查看下mysql 的配置文件裏是否設置了不區分大小寫,vim /etc/my.cnf
在 [mysqld] 模塊中添加:
lower_case_table_names=1
保存重啓mysql
其實準確來說不是說 Linux 對於 MySQL 表名忽略大小寫,而是應用上面的配置後,MySQL 服務程序會來自於應用程序裏的請求的表名轉換爲小寫,如你查詢 select* UNMI_TABLE,MySQL 會認爲是查詢的 select * from unmi_table,所以在加入
lower_case_table_names=1
之前時你必須把表名都改爲小寫。也就是在創建表時都用小寫名字,如果創建的表名爲 UNMI_TABLE,那麼程序中無論是執行 select * from UNMI_TABLE 還是執行 select * from unmi_table 都會碰到類似下面的錯誤:
Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't retrieve trigger: Table 'unmijob.qrtz_triggers' doesn't exist [See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'unmijob.qrtz_triggers' doesn't exist]
因爲 MySQL 服務程序認爲表名就是小寫的 unmi_table,而在數據庫中的表名不是這樣子的。
而且此時在 MySQL 客戶端都無法把 QRTZ_TRIGGERS 改成 qrtz_triggers. 因爲表名的大小寫是與文件系統中的數據目錄下的 frm 文件相對應的。