Hallo,
ich versuche beim Verbindungsaufbau eine Exception abzufangen, wenn z.B.
Username Passwort oder DB-Host nicht stimmen. Es kommt zwar auch eine
Exception aber sie wird irgendwie nicht geworfen so dass ich sie mit
catch abfangen könnte. Hat jemand eine Idee woran das liegt ?
Code:
try
{
emf = Persistence.createEntityManagerFactory("puname",props);
em = emf.createEntityManager();
}
catch (Exception e)
{
// Do something
}
Hier die Exception, welche kommt aber nicht geworfen wird ...
Code:
14:25:43,781 WARN SettingsFactory:117 - Could not obtain connection metadata
org.postgresql.util.PSQLException: FATAL: Passwort-Authentifizierung f?r Benutzer ?postgres? fehlgeschlagen
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
at org.postgresql.Driver.connect(Driver.java:267)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
at application.EmfThread.run(EmfThread.java:58)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Unknown Source)
at org.eclipse.swt.widgets.Display.syncExec(Unknown Source)
at gui.ConnectDialog.buttonWidgetSelected(ConnectDialog.java:224)
at gui.ConnectDialog.access$1(ConnectDialog.java:217)
at gui.ConnectDialog$5.widgetSelected(ConnectDialog.java:186)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at gui.ConnectDialog.<init>(ConnectDialog.java:61)
at application.Start.main(Start.java:9)
Hat jemand eine Idee wie ich an die Exception komme, um sie behandeln zu können ?
Moe