Hi all,
I'm using Hibernate 3.0.5 to store data into MySQL 5.0.16. The tables are created in database 'jsp' (lowercase) via hbm2ddl.auto=update - on the first run, with empty DB everything works fine. However on any subsequent run Hibernate tries to read and eventually update the schema, but using upercase(!) database name 'JSP'. With most other DB engines this probably is not a problem, but MySQL is case sensitive and therefore database 'jsp' != 'JSP'.
Although schema update doesn't work the connection pool is created OK using lowercase DB name and the application continues as expected (unless the schema changes, of course).
The workaround is obviously using uppercase database name, then it works fine. But sometimes this isn't possible.
Is the described behaviour a bug or did I miss some config option somewhere?
Versions:
Hibernate 3.0.5, MySQL 5.0.16, MySQL J/Connector 3.1.11
Mapping documents:
hibernate.cfg.xml:
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://rumburak/jsp</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="
hbm2ddl.auto">
update</property>
Full stack trace of any exception that occurs:
Code:
Dec 17, 2005 11:27:15 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1049, SQLState: 42000
Dec 17, 2005 11:27:15 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Unknown database 'JSP'
Dec 17, 2005 11:27:15 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: could not complete schema update
org.hibernate.exception.JDBCConnectionException: could not get table metadata: USERS
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:94)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:744)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:135)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:265)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at logix.HibernateUtil.<clinit>(HibernateUtil.java:21)
at logix.User.save(User.java:56)
at logix.Main.main_hibernate(Main.java:11)
at logix.Main.main(Main.java:68)
Caused by: java.sql.SQLException: Unknown database 'JSP'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2972)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:822)
at com.mysql.jdbc.DatabaseMetaData$9.forEach(DatabaseMetaData.java:4453)
at com.mysql.jdbc.DatabaseMetaData$IterateBlock.doForAll(DatabaseMetaData.java:79)
at com.mysql.jdbc.DatabaseMetaData.getTables(DatabaseMetaData.java:4440)
at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:1928)
at com.mysql.jdbc.DatabaseMetaData$IterateBlock.doForAll(DatabaseMetaData.java:79)
at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:1894)
at org.hibernate.tool.hbm2ddl.TableMetadata.initColumns(TableMetadata.java:173)
at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata.java:33)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:79)
... 8 more
Dec 17, 2005 11:27:15 PM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:mysql://rumburak/jsp?useUnicode=true&characterEncoding=UTF-8
Name and version of the database you are using:
MySQL 5.0.16, MySQL J/Connector 3.1.11