Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 5031F2E3356 for ; Thu, 6 Dec 2007 05:42:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 63304-07 for ; Thu, 6 Dec 2007 05:42:22 -0400 (AST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.181]) by postgresql.org (Postfix) with ESMTP id 970862E3363 for ; Thu, 6 Dec 2007 05:42:24 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so442688waf for ; Thu, 06 Dec 2007 01:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=BIMyAvpc2ZxVNPApyrXkOO13QZirdQDlfHwTDq8nL0U=; b=UCbU8YxANv3y464PqlVCF+J8PoCp1JaUM+TSzkZCOjiAh+F0Kzb9BUylAHA3z3wfIfa+P3sG7+Mj5OltkyimR/QLj/A7kXiy6mjErzglOAKpf2l7d0FbING1zoccLyhPFBT1Mcgi1BYhG6Yb5BDNSqEzXsYySJTCH9mALJnOoyA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=IuiH98xjjqvuel13jxcEhSn0GT8O+U/vRoJ2IuId0x9TOmnCvrDbN9MqGMwVN/OWBdxlxHGZ6vP77GkkToGHhBAHcZzK9B+0g5Lq682BsrZDweIWBpT/tRGhgyQkEeRehANvtd5HAkHujxzWTWZ66iLIXRINcfOAfshUu71Qc5M= Received: by 10.115.33.1 with SMTP id l1mr821911waj.1196934142572; Thu, 06 Dec 2007 01:42:22 -0800 (PST) Received: by 10.114.208.9 with HTTP; Thu, 6 Dec 2007 01:42:22 -0800 (PST) Message-ID: <4478b4ac0712060142l2b185543y2d598d940e555c74@mail.gmail.com> Date: Thu, 6 Dec 2007 15:12:22 +0530 From: "Kranti K K Parisa [GetSet-India]" To: "Kris Jurka" Subject: Re: BatchUpdate exception Cc: pgsql-jdbc@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1988_20830118.1196934142565" References: <4478b4ac0712050624u18cf3e8en81990c67ddf9da92@mail.gmail.com> <4478b4ac0712050752kae43d65p46c5c08645d1e755@mail.gmail.com> <4478b4ac0712050802g595852dcq8a1e2efb886c5853@mail.gmail.com> <4478b4ac0712052314p8a1875dm424b8e8c7645b0df@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/44 X-Sequence-Number: 17899 ------=_Part_1988_20830118.1196934142565 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Kris, I realized it after posting it and then i have changed it to the following ----------------------------- CallableStatement proc=null; try{ for (int i=0;i<200;i++){ //System.out.println("inside outer==>>"+i); for(int j=0;j<4;j++){ //System.out.println("inside inner==>>"+j); proc=con.prepareCall("{call test_function()}"); //proc.registerOutParameter(1, Types.INTEGER); proc.addBatch(); } } int []intUpdates=proc.executeBatch(); System.out.println("intUpdates length==>>"+intUpdates.length); for(int i=0;i>"+i); System.out.println("i value is==>>"+intUpdates[i]); al.add(new Integer(intUpdates[i])); } }catch(SQLException e){ System.out.println(e.getNextException()); } -------------------------- But the output remains same, which is ---------- intUpdates length==>>1 i number is==>>0 i value is==>>0 test size===>>[0] ------------------ Please suggest On Dec 6, 2007 3:09 PM, Kris Jurka wrote: > > > On Thu, 6 Dec 2007, Kranti K K Parisa [GetSet-India] wrote: > > > for (int i=0;i<200;i++){ > > //System.out.println("inside outer==>>"+i); > > for(int j=0;j<4;j++){ > > proc=null; > > //System.out.println("inside inner==>>"+j); > > proc=con.prepareCall("{call > > client255271111.test_function()}"); > > //proc.registerOutParameter(1, Types.INTEGER); > > proc.addBatch(); > > } > > } > > int []intUpdates=proc.executeBatch(); > > > Since you're reinitializing proc inside the loop you only end up adding > one batch to it, so you only get one batch out. > > Kris Jurka > -- ------------------ Best Regards Kranti Kiran Kumar Parisa Mobile: +91 - 9849 - 625 - 625 +91 - 9391 - 438 - 738 ------=_Part_1988_20830118.1196934142565 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Kris,

I realized it after posting it and then i have changed it to the following

-----------------------------
CallableStatement proc=null;
       
        try{
            for (int i=0;i<200;i++){
                //System.out.println("inside outer==>>"+i);
                for(int j=0;j<4;j++){
                    //System.out.println("inside inner==>>"+j);
                    proc= con.prepareCall("{call test_function()}");
                    //proc.registerOutParameter(1, Types.INTEGER);
                    proc.addBatch();
                }
            }
            int []intUpdates= proc.executeBatch();
            System.out.println("intUpdates length==>>"+intUpdates.length);
            for(int i=0;i<intUpdates.length;i++){
                System.out.println("i number is==>>"+i);
                System.out.println("i value is==>>"+intUpdates[i]);
                al.add(new Integer(intUpdates[i]));
            }
        }catch(SQLException e){
            System.out.println (e.getNextException());
        }
--------------------------

But the output remains same, which is

----------
intUpdates length==>>1
i number is==>>0
i value is==>>0
test size===>>[0]

------------------

Please suggest

On Dec 6, 2007 3:09 PM, Kris Jurka <books@ejurka.com> wrote:


On Thu, 6 Dec 2007, Kranti K K Parisa [GetSet-India] wrote:

>            for (int i=0;i<200;i++){
>                //System.out.println("inside outer==>>"+i);
>                for(int j=0;j<4;j++){
>                    proc=null;
>                    //System.out.println("inside inner==>>"+j);
>                    proc=con.prepareCall ("{call
> client255271111.test_function()}");
>                    //proc.registerOutParameter(1, Types.INTEGER);
>                    proc.addBatch();
>                }
>            }
>            int []intUpdates=proc.executeBatch();


Since you're reinitializing proc inside the loop you only end up adding
one batch to it, so you only get one batch out.

Kris Jurka



--
------------------
Best Regards
Kranti Kiran Kumar Parisa
Mobile: +91 - 9849 - 625 - 625
           +91 - 9391 - 438 - 738 ------=_Part_1988_20830118.1196934142565--