Java Jboss Hibernate Tools:读取错误模式 - 可能是 JDBC 驱动程序问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24995598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jboss Hibernate Tools: Reading error schema - Probably a JDBC driver Issue
提问by Harmeet Singh Taara
Hello i am trying to use JBoss Hibernate Tools for Reverse engineering. I am using eclipse luna
and latest hibernate jboss tools from eclipse market place. When i trying to configure the hibernate tools configuration, After configuration done, when i expand the tree and expand database
node, it generate an following error:
您好,我正在尝试使用 JBoss Hibernate 工具进行逆向工程。我正在使用eclipse luna
来自 eclipse 市场的最新 hibernate jboss 工具。当我尝试配置休眠工具配置时,配置完成后,当我展开树并展开database
节点时,会生成以下错误:
<Reading Schema Error: Could not get list of suggested identity strategies from database. Probably a JDBC Driver Problem>
Stack Trace:
堆栈跟踪:
org.hibernate.exception.SQLGrammarException: Could not get list of suggested identity strategies from database. Probably a JDBC driver problem.
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.cfg.reveng.dialect.MySQLMetaDataDialect.getSuggestedPrimaryKeyStrategyName(MySQLMetaDataDialect.java:55)
at org.hibernate.cfg.reveng.JDBCReader.processPrimaryKey(JDBCReader.java:429)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:86)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.execute(LazyDatabaseSchemaWorkbenchAdapter.java:126)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:115)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
at org.eclipse.ui.progress.DeferredTreeContentManager.run(DeferredTreeContentManager.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-empirecl-test like 'oauth_access_token'' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1062)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
My database connection with eclipse is build successfully beacause with the help of Database explore
by eclipse make connection successfully and also display all tables. I am using Hibernate 4.3
and latest MySQL driver 5.1.31
. Following are the screen shots of my configuration.
我与 eclipse 的数据库连接是成功建立的,因为在Database explore
eclipse的帮助下成功建立连接并显示所有表。我正在使用Hibernate 4.3
和最新的MySQL driver 5.1.31
. 以下是我的配置的屏幕截图。
Following is my hibernate.cfg.xml
file:
以下是我的hibernate.cfg.xml
文件:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/nit-empirecl-test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>
采纳答案by Harmeet Singh Taara
I found the solution, The problem is with database name. I don't know, but hibernate jboss tool, not support ( - )
Hyphen in database name. When i change the name with underscore the configuration will run successfully.
我找到了解决方案,问题出在数据库名称上。我不知道,但是 hibernate jboss 工具,不支持( - )
数据库名称中的连字符。当我用下划线更改名称时,配置将成功运行。
回答by Webaib
I have the same problem, but with MS SQL Server and without "-" in DB name. You can try to set the "optional" property hibernate.default_schema.
我有同样的问题,但是使用 MS SQL Server 并且数据库名称中没有“-”。您可以尝试设置“可选”属性 hibernate.default_schema。
回答by ttn
You should set the hibernate
default schema (for sql server)
您应该设置hibernate
默认架构(对于 sql server)
<property name="hibernate.default_schema">dbo</property>