From: David P. (JIRA) <no...@at...> - 2006-06-13 15:50:32
|
Not Generating HibernateException --------------------------------- Key: HHH-1833 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1833 Project: Hibernate3 Type: Bug Components: metamodel Environment: Hibernate3, Postgresql 8.1.404 Reporter: David Phan The Configuration.buildSessionFactory() method is supposed to throw a HibernateException. I have the following code snippet below. This is supposed to test if users enter the correct URL, username and password for a database. I would expect that if any of those is wrong the HibernateException would be thrown. But it's not. I believe the bug is in the org.hibernate.cfg.SettingsFactory class, where the SQLException is caught. All it does is logging a warning rather than throwing a HibernateException. If any of the URL, username, password is incorrect, then is there any reason to log a warning and then move forward? I don't think so. try { AnnotationConfiguration testSessionFactory = new AnnotationConfiguration(); //testSessionFactory.setProperty(Environment.HBM2DDL_AUTO, "update"); testSessionFactory.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); testSessionFactory.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver"); testSessionFactory.setProperty("hibernate.cache.use_second_level_cache", "false"); testSessionFactory.setProperty("hibernate.connection.url", url); testSessionFactory.setProperty("hibernate.connection.username", username); testSessionFactory.setProperty("hibernate.connection.password", password); testSessionFactory.buildSessionFactory(); success = true; } catch (HibernateException e) { // Log here that test fails System.out.println("Fail to connect to database: " + e.toString()); success = false; } catch (Throwable t) { success = false; } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |