Results 1 to 2 of 2
  1. #1
    lockev3.0 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default Driver.getConnection forever waiting

    Hi.
    I have a simple application to issue every x seconds a query against a remote database (mysql). I use the mysql jdbc4 driver and got a serious trouble :
    • My app is intended just to test connection to remote DB
    • If the remote host gets suddenly unplugged ==> my app won't ever respond no more and just will stay in the last connection trial forever.
    • If, at such moment, I issue netstat -patun | grep EST | grep my_remote_host, indeed the connection seems to remains there established forever unless I kill my little app.


    am i missing a base networking concept ? how else could I monitorize my connection to the remote db ?

    my chunk code (somewhere in that try it hooks, never returns neither throws Exception) :
    Java Code:
     try
                    {
                            System.err.print("[MonitorReplicaBD ("+m_lPeriodo+")]-"
                                    + (new GregorianCalendar().getTime())+" - ");
                            Class.forName(DEFAULT_DB_DRIVER);
                            if ( this.timeout != 0 )
                            {
                                    final InetAddress ia =
                                            InetAddress.getByName (m_sHost);
                                    final boolean reachable =
                                            ia.isReachable(timeout);
                                    if ( ! reachable )
                                    {
                                            ConnectException ce = new
                                             ConnectException("host unreachable");
    
                                            throw new SQLException(m_sHost + " OFF"
                                                                    , ce);
                                    }
                            }
                            final Connection conn = dameConexion();
                            final Statement st = conn.createStatement();
                            final ResultSet rs = st.executeQuery(SQL_CHECK);
    }
                    //catch(CommunicationsException ce)
                    catch(SQLException sqle)
                    {
                            //TODO: ACCION ALERTA
                            System.err.println(" ERROR: "+ sqle.getClass().getName()
                                    + " CAUSE: " + sqle.getCause());
                    }
                    catch(Throwable t)
                    {
                            t.printStackTrace();
                    }



    Thanks in advance.

  2. #2
    lockev3.0 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default Me myself I will respond

    Some missing data I forgot to tell and which seems to be the cause of the problem: the above commented machines are virtualized.
    Now my doubt is, shouldn't network layer be transparent when virtualized ?

Similar Threads

  1. Problem with getConnection
    By juamd in forum Networking
    Replies: 9
    Last Post: 04-09-2010, 12:53 PM
  2. Replies: 0
    Last Post: 09-11-2009, 06:53 PM
  3. [SOLVED] How to loop forever
    By Manfizy in forum New To Java
    Replies: 18
    Last Post: 06-19-2009, 09:59 AM
  4. Replies: 0
    Last Post: 04-21-2009, 02:32 AM
  5. DriverManger.getConnection
    By mransome in forum Advanced Java
    Replies: 1
    Last Post: 08-13-2007, 03:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •