org.quartz.JobPersistenceException: Couldn't retrieve trigger: Table 'leo_quartz.QRTZ_TSSDRS' does

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulerFactoryBean' defined in class path resource [cn/leopard/service/quartz/SchedulerConfig.class]: Invocat
ion of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't retrieve trigger: Table 'leo_quartz.QRTZ_TSSDRS' doesn't exist [See nested exception: com.mysql.jdbc.excep
tions.jdbc4.MySQLSyntaxErrorException: Table 'leo_quartz.QRTZ_TSSDRS' doesn't exist]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
	at cn.leopard.service.ipc.Application.main(Application.java:26)
使用到了 Quartz 集群的特性,所以建了 MySql 的中间表,此错误显示的“QRTZ_TSSDRS”表是存在,但却找不出,查找网上资料,可能是由于linux对大小写敏感判断导致,代码中的 sql 语句表明也都是用小写,所以未碰到。现在 Quartz 偏喜欢大写,问题也就这样来了。

知道原因,找解决办法就可有的放矢了,google mysql linux 表名不区分大小写,答案立马找到:

需要改 MySQL 的配置文件,Linux 下 MySQL 的配置文件可能是 /etc/my.cnf,或 /etc/mysql/my.cnf,这依赖于你的安装方式。假如是 /etc/my.cnf,那么执行

sudo vi /etc/my.cnf

在 [mysqld] 节中添加:

lower_case_table_names=1

然后保存,用 sudo /etc/init.d/mysql restart 重启 MySQL 服务便让 Linux 系统对表名大小写不敏感了。

其实准确来说不是说 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_TSSDRS 改成 qrtz_triggers. 因为表名的大小写是与文件系统中的数据目录下的 frm 文件相对应的。

文章参考链接:https://unmi.cc/linux-mysql-lower-case-table-names/
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值