hi!
when you build a SessionFactory for a Database that does not exist,
an exception is thrown and logged.
however, i can NOT catch that exception.
what am i doing wrong?
my code:
try {
Configuration cfg = HibernateSessionPool.buildConfiguration(ds);
cfg.setProperty("hibernate.hbm2ddl.auto","create");
SessionFactory sf = cfg.buildSessionFactory();
} catch (Exception ex) {
// Make sure you log the exception, as it might be swallowed
logger.severe("Initial SessionFactory creation failed.");
throw new ExceptionInInitializerError(ex);
}
the stack trace says the exception is thrown in the last line of the try
block. however, the catch block is never entered. i have
no chance to catch the exception...
any clue?
Hibernate version:
3.0.5
Full stack trace of any exception that occurs:
INFO - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/xx
INFO - connection properties: {user=xx, password=****}
ERROR - schema export unsuccessful
java.sql.SQLException: Unknown database 'xx'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2921)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:770)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3641)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1175)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2544)
at com.mysql.jdbc.Connection.<init>(Connection.java:1474)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.getConnection(SchemaExport.java:432)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:99)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:264)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at net.bitalchemy.omnitheca.persistence.StorageTools.exportSchema(StorageTools.java:51)
Name and version of the database you are using:
MySQL
|