-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: unable to catch exception in new Configuration()
PostPosted: Tue Nov 29, 2005 3:35 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
I have this code in the method main of my app:
Configuration cfg = new Configuration();
How can I catch the exceptions generated by this line?
The excpetion hasn't been catched by the try..catch block.
For example, I has put some different user and password, and the exception has not been catched.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 4:48 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
I believe in Hibernate 3.x HibernateException now extends RuntimeException, so you'd want to catch (Throwable t) instead of catch (Exception e).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 5:48 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
This doesn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 6:02 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
What is the code you have?
What is the exception?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 6:44 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
Code:
    public static void main(String[] args) {   
       Splash.getInstance().openSplash();
       try{
          GerenciadorPersistencia.criarFabricaSessoes();
       }catch(Throwable t){
          JOptionPane.showMessageDialog(null,"Erro ao criar fábrica de sessões",
                "Não foi possível criar fábrica de sessões. Talvez ocorreu um erro de conexão com o banco de dados.\n"+
                t.getCause()==null?t.getMessage():t.getMessage()+" "+t.getCause(),
                      JOptionPane.ERROR_MESSAGE);
       }


There is a looping printing these exception several times...until I stop the program. I changed the user name and password to force the exception, to test the code.

Code:
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@187814 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@172e449 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 3000, initialPoolSize -> 5, maxIdleTime -> 300, maxPoolSize -> 20, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@41d05d [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:firebirdsql://servidor:3050/c:\SOR\BANCO.FDB, properties -> {user=******, password=******, lc_ctype=WIN1252} ] , preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ] , factoryClassLocation -> null, numHelperThreads -> 3, poolOwnerIdentityToken -> 187814 ]
org.firebirdsql.jdbc.FBSQLException: Resource Exception. Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
Reason: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
   at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:112)
   at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:189)
   at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
   at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
   at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
   at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
   at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
   at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
at org.firebirdsql.gds.GDSException: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
   at org.firebirdsql.jgds.GDS_Impl.readStatusVector(GDS_Impl.java:1816)
   at org.firebirdsql.jgds.GDS_Impl.receiveResponse(GDS_Impl.java:1769)
   at org.firebirdsql.jgds.GDS_Impl.isc_attach_database(GDS_Impl.java:303)
   at org.firebirdsql.jgds.GDS_Impl.isc_attach_database(GDS_Impl.java:265)
   at org.firebirdsql.jca.FBManagedConnectionFactory.createDbHandle(FBManagedConnectionFactory.java:562)
   at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:90)
   at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:388)
   at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:60)
   at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:109)
   at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:189)
   at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
   at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
   at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
   at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
   at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
   at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 6:48 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
After several attempts, these last lines are showed:

Quote:
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
to succeed more than the maximum number of allowed
com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6ac461 -- Acquisition Attempt Failed!!! Clearing pending acquires.
acquisition attempts (30).
While trying to acquire a needed new resource, we failed
to succeed more than the maximum number of allowed
acquisition attempts (30).
20:43:18,920java.sql.SQLException: An SQLException was provoked by the following failure: com.mchange.v2.resourcepool.ResourcePoolException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:68)
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:57)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:213)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:64)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at src.model.GerenciadorPersistencia.criarFabricaSessoes(GerenciadorPersistencia.java:19)
at src.IniciarAplicacao.main(IniciarAplicacao.java:39)
Caused by: com.mchange.v2.resourcepool.ResourcePoolException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAcquire(BasicResourcePool.java:870)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:201)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:209)
... 7 more
20:43:19,130


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 6:50 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
I forget to show you the code or GerenciadorPersistencia.criarFabricaSessoes

Code:
   public static void criarFabricaSessoes(){
      Configuration cfg = new Configuration();
      sessionFactory = cfg.configure().buildSessionFactory();
   }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 9:27 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
And you are saying that your showMessageDialog never shows up?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 7:42 am 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
Yes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.