Hi,
After several hours with no activity my connection
pool
seems to get garbage collected (or die). It works
fine,
but then I come in the next day and get the following
error:
java.sql.SQLException:
Communication link failure: java.net.SocketException
The full stack trace is at the bottom of the page. If
I reload the page in question a couple of times the
connection comes back and everything is o.k.
I am working on my own so I need some help. I've
included the data-sources section of the
struts-config.xml file and the database related part
of my perform method below.
Any insight would be greatly appreciated.
Thanks,
Ellen
//--
//-- in the struts-config.xml
//--
//--
//-- in my Action class
//--
public ActionForward perform(...) throws ...
GenericConnection connection = null;
try {
DataSource ds = servlet.findDataSource(null);
connection =
(GenericConnection) ds.getConnection();
String sql = "select * from mytable";
Statement statement =
connection.createStatement();
ResultSet results =
statement.executeQuery(sql);
while (results.next()) {
// stuff goes here
}
connection.close();
results = null;
statement = null;
connection = null;
}
catch (SQLException se) {
request.setAttribute("exception", se);
return (mapping.findForward("failure"));
}
finally {
// Return connection to pool
if (connection != null) {
try {
connection.close();
}
connection = null;
}
}
}
//--
// exception.printStackTrace()
//--
java.sql.SQLException: Communication link failure:
java.net.SocketException
at java.lang.Throwable.fillInStackTrace(Native
Method)
at
java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at
java.sql.SQLException.(SQLException.java:43)
at
org.gjt.mm.mysql.MysqlIO.sendCommand(Compiled Code)
at
org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Compiled Code)
at org.gjt.mm.mysql.MysqlIO.sqlQuery(Compiled
Code)
at
org.gjt.mm.mysql.Connection.execSQL(Compiled Code)
at
org.gjt.mm.mysql.Connection.execSQL(Compiled Code)
at
org.gjt.mm.mysql.Statement.executeQuery(Compiled Code)
at
org.gjt.mm.mysql.jdbc2.Statement.executeQuery(Compiled
Code)
at planner.ShowReleasesAction.perform(Compiled
Code)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1634)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1444)
at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:472)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at
javax.servlet.http.HttpServlet.service(Compiled Code)
at
org.apache.tomcat.core.ServletWrapper.doService(Compiled
Code)
at
org.apache.tomcat.core.Handler.service(Compiled Code)
at
org.apache.tomcat.core.ServletWrapper.service(Compiled
Code)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at
org.apache.tomcat.core.ContextManager.service(Compiled
Code)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Compiled
Code)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled
Code)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled
Code)
at java.lang.Thread.run(Compiled Code)
__
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/