Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 41248 invoked from network); 6 May 2009 20:18:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 May 2009 20:18:28 -0000 Received: (qmail 21725 invoked by uid 500); 6 May 2009 20:18:27 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 21657 invoked by uid 500); 6 May 2009 20:18:27 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 21599 invoked by uid 99); 6 May 2009 20:18:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 May 2009 20:18:27 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of nathan.maves@gmail.com designates 209.85.218.177 as permitted sender) Received: from [209.85.218.177] (HELO mail-bw0-f177.google.com) (209.85.218.177) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 May 2009 20:18:19 +0000 Received: by bwz25 with SMTP id 25so402074bwz.0 for ; Wed, 06 May 2009 13:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=ZT2OqYFOITXUfzl9T+KH6Gb99UwTojcB2dwoXyxh22g=; b=oDgDkZIzLfEyMKrNamXH3Jd+KCMZ0fYa80+Dr/ft33gPCBz3lvUGsJvDXInkHmvolk UMVEMs8myLEzAj6BsYZP4y0KPMZMTw+kSpNFFOJlrVO48hL/R8kHBa1BgH/AgSqNymcZ Xfernn75yF3IbBO9uCNKCLsVhkb8RMI3+wH1Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=rh6HBQuS3wwT5PKK27m+EKFimLbqK1dVlO6mjyyGURZF6eEaNU+kIe4tWv5PMa0dJL N4UePEtVPNmIUVNdDY30od8bmMEFtjsjiY+OsINX2L4x7KHYLLo9isXrDBxlkwLNeujS CIYGvvt8b/Eoy1gbURHORu3NG05kJwjEOc5Kw= MIME-Version: 1.0 Received: by 10.223.111.211 with SMTP id t19mr1247867fap.64.1241641077071; Wed, 06 May 2009 13:17:57 -0700 (PDT) In-Reply-To: <878c6f8e0905040703s19e19137ve5d3e4d6ff5959e0@mail.gmail.com> References: <878c6f8e0905040703s19e19137ve5d3e4d6ff5959e0@mail.gmail.com> From: Nathan Maves Date: Wed, 6 May 2009 14:17:37 -0600 Message-ID: <2f55db670905061317y2e48fde3n435d3adec79d85ad@mail.gmail.com> Subject: Re: How to test Pool.PingQuery with Simple Datasource To: user-java@ibatis.apache.org Content-Type: multipart/alternative; boundary=0016e6d376615672560469441792 X-Virus-Checked: Checked by ClamAV on apache.org --0016e6d376615672560469441792 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 wrote: > HiI have configured my data Source as below > > > /> > value="jdbc:as400:MYAS400/MYDB;naming=system;date format=iso;time > format=hms;prompt=false" /> > > > value="Select TYPE FROM APP_TYPE" /> > > > > > > > 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. > > > > > > > > --0016e6d376615672560469441792 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =3D true;

try {
result =3D !con= n.getRealConnection().isClosed();
} catch (SQLException e) {
= if (log.isDebugEnabled()) {
log.debug("Connection " + conn.getRealHashCode() + "= is BAD: " + e.getMessage());
}
result =3D fals= e;
}

if (result) {
if (poolPingEnabled) {
if ((poolPingConnectionsOlderThan > 0 && conn.getAge() &= gt; poolPingConnectionsOlderThan)
|| (poolPingConnectionsNotUsedFor > 0 && conn.getTim= eElapsedSinceLastUse() > poolPingConnectionsNotUsedFor)) {

= try {
if (log.isDebugEnabled()) {
log.d= ebug("Testing connection " + conn.getRealHashCode() + " ...&= quot;);
}
Connection realConn =3D conn.getRealConnection= ();
Statement statement =3D realConn.createStatement();
= ResultSet rs =3D statement.executeQuery(poolPingQuery);
= rs.close();
statement.close();
if (!realConn.getAutoCommit()= ) {
realConn.rollback();
}
r= esult =3D true;
if (log.isDebugEnabled()) {
= log.debug("Connection " + conn.getRealHashCode() + " is GOO= D!");
}
} catch (Exception e) {
log.warn(= "Execution of ping query '" + poolPingQuery + "' fai= led: " + e.getMessage());
try {
= conn.getRealConnection().close();
} catch (Exception e2) {
//ignore
= }
result =3D false;
if (log.isDebugEnabled= ()) {
log.debug("Connection " + conn.getRealHash= Code() + " is BAD: " + e.getMessage());
}
}
}
}
}
return= result;
}

you can see that there are debug statements in= there that you should be seeing in your log.=C2=A0 I would set the ping ti= mes really low to test that you see these messages.




On Mon, May 4, 2009 at 8:03 AM, = Ashish Kulkarni <ashish.kulkarni13@gmail.com> wrote:
Hi
I have configured my data Source as below
<transac= tionManager type=3D"JDBC">
<dataSource type=3D"SIMPLE">
<property name=3D"= JDBC.Driver" value=3D"com.ibm.as400.access.AS400JDBCDriver" = />
<property na= me=3D"JDBC.ConnectionURL" value=3D"jdbc:as400:MYAS400/MYDB;n= aming=3Dsystem;date format=3Diso;time format=3Dhms;prompt=3Dfalse" /&g= t;
<property name=3D= "JDBC.Username" value=3D"user" />
<property name=3D"JDBC.Pass= word" value=3D"password" />
<property name=3D= "Pool.PingQuery"
= value=3D"Select TYPE FROM APP_TYPE" />
<property name=3D"= Pool.PingEnabled" value=3D"true" />
<property name=3D"Pool.PingConnect= ionsOlderThan" value=3D"0" />
<property name=3D"= Pool.PingConnectionsNotUsedFor" value=3D"0" />
= </dataSource>
</transactionManager>

In my Log4j= .xml i have following lines to debug all queries, but i do not see any Ping= Query 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=C2=A0Pool.= PingConnectionsOlderThan to=C2=A01800000 and Pool.PingConnectionsNotUsedFor= to 1800000 so to use PingQuery if the connection is older then 30 minutes.=

=C2=A0<category name=3D"com.ibatis"&g= t;
<priority value= =3D"DEBUG" />
</category>
<category name=3D"java.sql">
<priority value=3D"DEBUG" />
</category>

--0016e6d376615672560469441792--