jdbc4.MySQLSyntaxErrorException:数据库中不存在表 [英] jdbc4.MySQLSyntaxErrorException: Table doesn't exist in database

查看:527
本文介绍了jdbc4.MySQLSyntaxErrorException:数据库中不存在表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SpringBoot开发一个Web应用程序,这是我的application.properties文件,用于指定访问数据库的凭据:

I'm developing a web app using SpringBoot, and this is my application.properties file to specify the credentials to access to the database:

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/Salamander
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

但是当我尝试运行SpringBoot应用程序时,它给了我这个错误:

but when I try to run the SpringBoot app, it gives me this error:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'salamander.user' doesn't exist
    at sun.reflect.GeneratedConstructorAccessor72.newInstance(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_40]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_40]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.Util.getInstance(Util.java:387) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:939) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962) ~[mysql-connector-java-5.1.38.jar:5.1.38]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
    ... 69 common frames omitted

我当然有一个名为user的实体,但是数据库为空.但是

Of course I've an entity called user, but the database is empty. But

spring.jpa.hibernate.ddl-auto=create-drop

应该说要休眠以在db中再次创建表,对吗?所以有什么问题?

should say to hibernate to create the tables again in the db, right? So what's the problem?

如果我使用远程数据库执行相同的操作,即使远程数据库为空,它也可以正常工作.

If I do the same but with a remote database, it works, even if the remote db is empty.

推荐答案

此问题已通过删除而得以解决 spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialec‌t

this issue was fixed by removing spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialec‌​t

这篇关于jdbc4.MySQLSyntaxErrorException:数据库中不存在表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆