Results 1 to 2 of 2
- 11-30-2010, 02:52 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
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.
- 12-09-2010, 08:59 AM #2
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Problem with getConnection
By juamd in forum NetworkingReplies: 9Last Post: 04-09-2010, 11:53 AM -
UnsupportedCharsetException in DriverManager.getConnection( String url )...
By Lee.J.Baxter in forum Advanced JavaReplies: 0Last Post: 09-11-2009, 05:53 PM -
[SOLVED] How to loop forever
By Manfizy in forum New To JavaReplies: 18Last Post: 06-19-2009, 08:59 AM -
JUnit is working properly, but takes forever to display results
By mnk007 in forum EclipseReplies: 0Last Post: 04-21-2009, 01:32 AM -
DriverManger.getConnection
By mransome in forum Advanced JavaReplies: 1Last Post: 08-13-2007, 02:16 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks