I'm in the process of attempting to use Derby with Tomcat and it's built-in
connection pool. I'm wondering if Derby's JDBC driver as an "autoReconnect"
property like MySQL has which will automatically reestablish a connection
that has been broken? Failing that, I'm wondering if anyone has an idea for
a simple query that could be used as a validation query to verify that the
connection is valid. Tomcat's connection pool lets you specify a query that
is tried on connections before it hands them out to you that way you know
that the connection is valid (i.e. the connection hasn't been timed out by
the server or otherwise dropped to to network failure and the like). For
other DBMSes, I've used a simple query of "SELECT '1'". However, this
doesn't appear to be a valid SQL statement in Derby. Has anyone else ran
into this problem?
<Context>
<Resource name="jdbc/..."
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.ibm.db2.jcc.DB2Driver"
url="jdbc:derby:net://localhost:1527/..."
username="..."
password="..."
maxActive="5"
maxIdle="5"
maxWait="60000"
validationQuery="SELECT '1'"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"/>
</Context>
Jon