Re: BatchUpdate exception - Mailing list pgsql-jdbc

From Kranti K K Parisa [GetSet-India]
Subject Re: BatchUpdate exception
Date
Msg-id 4478b4ac0712060142l2b185543y2d598d940e555c74@mail.gmail.com
Whole thread Raw
In response to Re: BatchUpdate exception  (Kris Jurka <books@ejurka.com>)
Responses Re: BatchUpdate exception
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: BatchUpdate exception
Next
From: Kris Jurka
Date:
Subject: Re: BatchUpdate exception