Java – Jboss Hibernate Tools: Reading error schema – Probably a JDBC driver Issue

hibernatejavajbossreverse-engineering

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:

<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$2.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$1.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.

  1. enter image description here

  2. enter image description here

Following is my hibernate.cfg.xml file:

<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>

Best Solution

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.

Related Question