-->
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.  [ 1 post ] 
Author Message
 Post subject: Communications link failure
PostPosted: Sat Apr 16, 2011 4:45 am 
Newbie

Joined: Sat Apr 16, 2011 4:35 am
Posts: 1
When my applications starts it first connect to the database to load some orders. When my database is unavailable I want to catch the error and show some message. But it seems I can't catch the error below. This is the code where the error occurs. I already try to catch it with "Throwable", "Exception".

I'm using Hibernate 3.6.
Code:
       try {
           Configuration conf = new Configuration();
           conf.configure("hibernateMySQL.cfg.xml");
           [color=#FF0000]_sessionFactory = conf.buildSessionFactory();[/color]
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            //throw new ExceptionInInitializerError(ex);
        }

Code:
10:23:53,820  WARN SettingsFactory:147 - Could not obtain connection to query metadata
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
   at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)
   at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
   at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308)
   at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
   at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
   at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
   at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
   at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:113)
   at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2836)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2832)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
   at be.deliche.ordermanager.model.persistence.HibernateUtil.<clinit>(HibernateUtil.java:17)
   at main.main(main.java:19)
Caused by: java.net.ConnectException: Connection timed out: connect
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(Unknown Source)
   at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
   at java.net.PlainSocketImpl.connect(Unknown Source)
   at java.net.SocksSocketImpl.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at java.net.Socket.<init>(Unknown Source)
   at java.net.Socket.<init>(Unknown Source)
   at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
   at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
   ... 20 more
10:23:53,929  INFO BasicTypeRegistry:150 - Type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.CharacterArrayClobType@68a53de4
10:23:53,929  INFO BasicTypeRegistry:150 - Type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.WrappedMaterializedBlobType@38827968
10:23:53,931  INFO BasicTypeRegistry:150 - Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType@435bb0f
10:23:53,932  INFO BasicTypeRegistry:150 - Type registration [blob] overrides previous : org.hibernate.type.BlobType@638bd7f1
10:23:53,932  INFO BasicTypeRegistry:150 - Type registration [java.sql.Blob] overrides previous : org.hibernate.type.BlobType@638bd7f1
10:23:53,932  INFO BasicTypeRegistry:150 - Type registration [materialized_clob] overrides previous : org.hibernate.type.MaterializedClobType@720e4245
10:23:53,932  INFO BasicTypeRegistry:150 - Type registration [clob] overrides previous : org.hibernate.type.ClobType@620fa83
10:23:53,933  INFO BasicTypeRegistry:150 - Type registration [java.sql.Clob] overrides previous : org.hibernate.type.ClobType@620fa83
10:23:53,933  INFO BasicTypeRegistry:150 - Type registration [characters_clob] overrides previous : org.hibernate.type.PrimitiveCharacterArrayClobType@5f1eb199
10:24:15,328 ERROR SchemaExport:287 - schema export unsuccessful
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
   at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)
   at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
   at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308)
   at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
   at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
   at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
   at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
   at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
   at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
   at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:263)
   at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:219)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:372)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
   at be.deliche.ordermanager.model.persistence.HibernateUtil.<clinit>(HibernateUtil.java:17)
   at main.main(main.java:19)
Caused by: java.net.ConnectException: Connection timed out: connect
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(Unknown Source)
   at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
   at java.net.PlainSocketImpl.connect(Unknown Source)
   at java.net.SocksSocketImpl.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at java.net.Socket.<init>(Unknown Source)
   at java.net.Socket.<init>(Unknown Source)
   at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
   at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
   ... 21 more



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

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.