based on the source located here
http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-2/ibatis-2-core/src/com/ibatis/common/jdbc/SimpleDataSource.java
private boolean pingConnection(SimplePooledConnection conn) {
boolean result = true;
try {
result = !conn.getRealConnection().isClosed();
} catch (SQLException e) {
if (log.isDebugEnabled()) {
log.debug("Connection " + conn.getRealHashCode() + " is BAD: "
+ e.getMessage());
}
result = false;
}
if (result) {
if (poolPingEnabled) {
if ((poolPingConnectionsOlderThan > 0 && conn.getAge() >
poolPingConnectionsOlderThan)
|| (poolPingConnectionsNotUsedFor > 0 &&
conn.getTimeElapsedSinceLastUse() > poolPingConnectionsNotUsedFor)) {
try {
if (log.isDebugEnabled()) {
log.debug("Testing connection " + conn.getRealHashCode()
+ " ...");
}
Connection realConn = conn.getRealConnection();
Statement statement = realConn.createStatement();
ResultSet rs = statement.executeQuery(poolPingQuery);
rs.close();
statement.close();
if (!realConn.getAutoCommit()) {
realConn.rollback();
}
result = true;
if (log.isDebugEnabled()) {
log.debug("Connection " + conn.getRealHashCode() + " is GOOD!");
}
} catch (Exception e) {
log.warn("Execution of ping query '" + poolPingQuery + "'
failed: " + e.getMessage());
try {
conn.getRealConnection().close();
} catch (Exception e2) {
//ignore
}
result = false;
if (log.isDebugEnabled()) {
log.debug("Connection " + conn.getRealHashCode() + " is
BAD: " + e.getMessage());
}
}
}
}
}
return result;
}
you can see that there are debug statements in there that you should be
seeing in your log. I would set the ping times really low to test that you
see these messages.
On Mon, May 4, 2009 at 8:03 AM, Ashish Kulkarni <[email protected]
> wrote:
> HiI have configured my data Source as below
> <transactionManager type="JDBC">
> <dataSource type="SIMPLE">
> <property name="JDBC.Driver" value="com.ibm.as400.access.AS400JDBCDriver"
> />
> <property name="JDBC.ConnectionURL"
> value="jdbc:as400:MYAS400/MYDB;naming=system;date format=iso;time
> format=hms;prompt=false" />
> <property name="JDBC.Username" value="user" />
> <property name="JDBC.Password" value="password" />
> <property name="Pool.PingQuery"
> value="Select TYPE FROM APP_TYPE" />
> <property name="Pool.PingEnabled" value="true" />
> <property name="Pool.PingConnectionsOlderThan" value="0" />
> <property name="Pool.PingConnectionsNotUsedFor" value="0" />
> </dataSource>
> </transactionManager>
>
> In my Log4j.xml i have following lines to debug all queries, but i do not
> see any PingQuery log in my log files, what am i missing, what is the way to
> make sure that Pool.PingQuery is working as expected, i am going to
> change Pool.PingConnectionsOlderThan to 1800000 and
> Pool.PingConnectionsNotUsedFor to 1800000 so to use PingQuery if the
> connection is older then 30 minutes.
>
> <category name="com.ibatis">
> <priority value="DEBUG" />
> </category>
> <category name="java.sql">
> <priority value="DEBUG" />
> </category>
>