Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 52644 invoked from network); 18 May 2006 20:05:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 May 2006 20:05:20 -0000 Received: (qmail 73246 invoked by uid 500); 18 May 2006 20:05:19 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 72958 invoked by uid 500); 18 May 2006 20:05:18 -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 72944 invoked by uid 99); 18 May 2006 20:05:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 May 2006 13:05:17 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of ericblue76@gmail.com designates 64.233.166.181 as permitted sender) Received: from [64.233.166.181] (HELO py-out-1112.google.com) (64.233.166.181) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 May 2006 13:05:17 -0700 Received: by py-out-1112.google.com with SMTP id b36so632484pyb for ; Thu, 18 May 2006 13:04:56 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=LoabYCBx0yAFzkt+qw+uVGgyGEVQ3VhyZo0H8VaZAI2rmJA6rdfmhqTvf3aEuKEz8mQRXlOu/yf5QB37SdlKdQpT/uMvOKkNd7DkQt8fhu/33mubB4kf8DE+YvqLLo8Cn1A78/mpyxsQLJt7fRMVFUDqjZjC0k9XeSg2SgrL5Sk= Received: by 10.35.91.15 with SMTP id t15mr971959pyl; Thu, 18 May 2006 13:04:56 -0700 (PDT) Received: by 10.35.9.12 with HTTP; Thu, 18 May 2006 13:04:56 -0700 (PDT) Message-ID: <295517f10605181304t3762a3fel43ebf51c79e73dee@mail.gmail.com> Date: Thu, 18 May 2006 13:04:56 -0700 From: "Eric T. Blue" To: user-java@ibatis.apache.org Subject: Re: Is it possible In-Reply-To: <093D7E25FD9C2441A13103EFB8CBED3A0AD922F0@nmr001oldmsx04.enterprisenet.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5862_16534025.1147982696353" References: <093D7E25FD9C2441A13103EFB8CBED3A0AD922F0@nmr001oldmsx04.enterprisenet.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_5862_16534025.1147982696353 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I do this programatically for a number of my unit tests. It's a little "hacky", but it works. int iterations =3D 1000; Logger statementLogger =3D Logger.getLogger("java.sql.PreparedStatement= "); statementLogger.setLevel(Level.DEBUG); WriterAppender appender =3D null; ByteArrayOutputStream stream =3D new ByteArrayOutputStream(); try { appender =3D new WriterAppender(new PatternLayout(), stream); } catch(Exception e) { fail("Appender exception: " + e); } statementLogger.addAppender(appender); String targetStatement =3D "SELECT * from my_table"; for (int i =3D 0; i < iterations; i++) { // Put DAO or SQLMap query here // Check to make sure that only the first get hits the database. // All subsequent calls should hit the cache. if ( (i > 0) && (stream.toString().contains(targetStatement)) ) { fail("Cache was not used and select statement detected on iteration " + i + ": " + stream.toString()); } stream.reset(); } On 5/18/06, Chen, Tim wrote: > > Actually I turned on JDBC logging (I think it explains how in the IBatis > log) using log4j and from that you can infer which goes out as queries an= d > which doesn't (which goes to cache). Don't know if there's another soluti= on > but it's really easy to do. > > ------------------------------ > *From:* Zacks, Michael [mailto:Michael_Zacks@ziffdavis.com] > *Sent:* Thursday, May 18, 2006 3:31 PM > *To:* user-java@ibatis.apache.org > *Subject:* Is it possible > > To determine whether query results were returned from the cache or from = a > trip to the database? I'm running Ibatis against SqlServer. My problem = is > that I have a query that was meant to be cached, but instead was being ru= n > every time against the database - much to the detriment of our applicatio= n. > I think I know what the problem is (I suspect it is an accidental 'select= * > from'), but I would like to be able to verify when database results came > from the cache or not. > > Thanks in advance. > > > > This e-mail message and any attachments to it are for the sole use of the > intended recipients and may contain confidential and privileged informati= on. > This e-mail message and any attachments are the property of Ziff Davis Me= dia > Inc. or its affiliates. Any unauthorized review, use, disclosure, or > distribution of this e-mail message or its attachments is prohibited. If = you > are not an intended recipient, please notify the sender by reply e-mail a= nd > destroy all copies of the original message and any attachments. Thank you= . > ------=_Part_5862_16534025.1147982696353 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I do this programatically for a number of my unit tests.  It's a littl= e "hacky", but it works.

<snip>

  &= nbsp; int iterations =3D 1000;
  
    Logge= r statementLogger =3D Logger.getLogger("java.sql.PreparedStatement ");
    statementLogger.setLevel(Level.DEBUG);
&n= bsp;  
    WriterAppender appender =3D null;    ByteArrayOutputStream stream =3D new ByteArrayOutputSt= ream();
    try {
      =   appender =3D new WriterAppender(new PatternLayout(), stream);
    } catch(Exception e) {
    &n= bsp;   fail("Appender exception: " + e);
  = ;  }
   
    statementLogger.addA= ppender(appender);
   
    String targ= etStatement =3D "SELECT * from my_table";
       
    for (= int i =3D 0; i < iterations; i++) {
    
&nbs= p;       // Put DAO or SQLMap query here
<= br>        // Check to make sure that on= ly the first get hits the database. 
     = ;   // All subsequent calls should hit the cache.
       
    =     if ( (i > 0) && (stream.toString().contains(t= argetStatement)) ) {
        &nb= sp;   fail("Cache was not used and select statement detected= on iteration "
        &n= bsp;           + i + &quo= t;: " +=20 stream.toString());         &n= bsp; 
        }
  =      
      &nbs= p; stream.reset();
         = ;      
    }

</= snip>

On 5/18/06, Chen, Tim <Tim.Chen@nielsenmedia= .com> wrote:
Actually I turned on JDBC logging (I think it explains how=20 in the IBatis log) using log4j and from that you can infer w= hich=20 goes out as queries and which doesn't (which goes to cache). Don't know if= =20 there's another solution but it's really easy to do.

From: Zacks, Michael=20 [mailto:Michael_Zacks@ziffda= vis.com]
Sent: Thursday, May 18, 2006=20 3:31 PM
To: user-j= ava@ibatis.apache.org
Subject: Is it=20 possible

To determine whether query results were = returned from=20 the cache or from a trip to the database?  I'm running Ibatis against= =20 SqlServer.  My problem is that I have a query that was meant to be cac= hed,=20 but instead was being run every time against the database - much to the=20 detriment of our application.  I think I know what the problem is (I= =20 suspect it is an accidental 'select * from'), but I would like to be able t= o=20 verify when database results came from the cache or not.

Thanks in advance.

 
 

This e-mail message and any attachments to it are for the sole use of th= e=20 intended recipients and may contain confidential and privileged information= .=20 This e-mail message and any attachments are the property of Ziff Davis Medi= a=20 Inc. or its affiliates. Any unauthorized review, use, disclosure, or=20 distribution of this e-mail message or its attachments is prohibited. If yo= u are=20 not an intended recipient, please notify the sender by reply e-mail and des= troy=20 all copies of the original message and any attachments. Thank=20 you.


------=_Part_5862_16534025.1147982696353--