connection reset
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sender_jones
Posted On:   Thursday, January 13, 2005 07:03 PM

I use Struts, Tomcat and MySQL. I have datasource in struts-config.xml like this: My coding looks like this: ServletContext context = servlet.getServletContext(); ds = (DataSource) context.getAttribute(ds_name); String find_cmd = ( "SELECT ......... try { conn = ds.getConnection(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery( find_cmd ); while ( rs.next() ) { .......... } //end while rs rs.close(); stmt.close(); conn.close(); } catch ( Exception ex ) { System.out.println(ex.getMessage()); } // end try catch    More>>

I use Struts, Tomcat and MySQL. I have datasource in struts-config.xml like this:

			













My coding looks like this:
			
ServletContext context = servlet.getServletContext();
ds = (DataSource) context.getAttribute(ds_name);
String find_cmd = ( "SELECT .........
try {
conn = ds.getConnection();
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery( find_cmd );
while ( rs.next() ) {
..........
} //end while rs
rs.close();
stmt.close();
conn.close();
} catch ( Exception ex ) {
System.out.println(ex.getMessage());
} // end try catch

My Tomcat is an always-on server. They work fine if the Tomcat is freshly started. But if the Tomcat stay overnight, when I execute the above coding next day, the first access always fail in getConnection() with exception saying "connection reset". However, the second and subsequent access work fine. Looks like an idle socket connection was dropped. Any solution?    <<Less
About | Sitemap | Contact