Driver.getConnection forever waiting
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) :
+ (new GregorianCalendar().getTime())+" - ");
if ( this.timeout != 0 )
final InetAddress ia =
final boolean reachable =
if ( ! reachable )
ConnectException ce = new
throw new SQLException(m_sHost + " OFF"
final Connection conn = dameConexion();
final Statement st = conn.createStatement();
final ResultSet rs = st.executeQuery(SQL_CHECK);
//TODO: ACCION ALERTA
System.err.println(" ERROR: "+ sqle.getClass().getName()
+ " CAUSE: " + sqle.getCause());
Thanks in advance.