Springboot和Mysql:找不到具有大写名称的表

时间:2019-05-13 09:51:52

标签: mysql spring-boot

在MySQL下,我的数据库中有这些表:

store_commercialRange Store

在我的springboot应用程序中,我用小写名称调用所有表,所以我这样称呼它:

store_commercialrange store

在我的/etc/mysql/my.cnf下,我已经设置了:

[mysqld]
lower_case_table_names = 1

我注意到以 Store 之类的大写字母开头的表的调用以 store 进行了传递,但是其他包含 的表 在中间 ,请勿通过。

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'myDatabase.store_commercialrange' doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_201]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_201]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_201]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_201]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.Util.getInstance(Util.java:387) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2550) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962) ~[mysql-connector-java-5.1.37.jar:5.1.37]
    at com.zaxxer.hikari.proxy.PreparedStatementProxy.executeQuery(PreparedStatementProxy.java:52) ~[HikariCP-java6-2.2.5.jar:na]
    at com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy.executeQuery(PreparedStatementJavassistProxy.java) ~[HikariCP-java6-2.2.5.jar:na]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]

1 个答案:

答案 0 :(得分:0)

我通过以下方式解决了它:

  1. 还原my.cnf的初始配置
  2. 删除我的数据库
  3. 停止mysql服务器
  4. 再次将此添加到/etc/mysql/my.cnf

    [mysqld]

    lower_case_table_names = 1

  5. 重新启动mysql服务