pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBatchUpdate exception
8+ messages / 2 participants
[nested] [flat]
* BatchUpdate exception
@ 2007-12-05 14:24 Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kranti K K Parisa [GetSet-India] @ 2007-12-05 14:24 UTC (permalink / raw)
To: pgsql-jdbc
hi,
I am trying to add the callable statement into a batch in a for loop. and
then execute that batch using executeBatch. which throws the following
exception.
org.postgresql.util.PSQLException: A result was returned when none was
expected.
any suggestions?
thanks in advance!
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-05 15:36 Kris Jurka <books@ejurka.com>
parent: Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kris Jurka @ 2007-12-05 15:36 UTC (permalink / raw)
To: Kranti K K Parisa \[GetSet-India\] <kranti.parisa@gmail.com>; +Cc: pgsql-jdbc
On Wed, 5 Dec 2007, Kranti K K Parisa [GetSet-India] wrote:
> I am trying to add the callable statement into a batch in a for loop. and
> then execute that batch using executeBatch. which throws the following
> exception.
>
> org.postgresql.util.PSQLException: A result was returned when none was
> expected.
>
This was fixed pretty recently and is only available in the 8.3dev series
of drivers. Please upgrade and retry.
Kris Jurka
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-05 15:52 Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kranti K K Parisa [GetSet-India] @ 2007-12-05 15:52 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Hi Kris,
Thanks for the reply.
We are using Postgres 8.1 version. Does this mean we need to upgrade the
database version also? or can use the driver with latest release?
On Dec 5, 2007 9:06 PM, Kris Jurka <books@ejurka.com> wrote:
>
>
> On Wed, 5 Dec 2007, Kranti K K Parisa [GetSet-India] wrote:
>
> > I am trying to add the callable statement into a batch in a for loop.
> and
> > then execute that batch using executeBatch. which throws the following
> > exception.
> >
> > org.postgresql.util.PSQLException: A result was returned when none was
> > expected.
> >
>
> This was fixed pretty recently and is only available in the 8.3dev series
> of drivers. Please upgrade and retry.
>
> Kris Jurka
>
>
--
------------------
Best Regards
Kranti Kiran Kumar Parisa
Mobile: +91 - 9849 - 625 - 625
+91 - 9391 - 438 - 738
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-05 15:56 Kris Jurka <books@ejurka.com>
parent: Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kris Jurka @ 2007-12-05 15:56 UTC (permalink / raw)
To: Kranti K K Parisa \[GetSet-India\] <kranti.parisa@gmail.com>; +Cc: pgsql-jdbc
On Wed, 5 Dec 2007, Kranti K K Parisa [GetSet-India] wrote:
> We are using Postgres 8.1 version. Does this mean we need to upgrade the
> database version also? or can use the driver with latest release?
>
You can use the 8.3 driver with any server version >= 7.2.
Kris Jurka
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-06 07:14 Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kranti K K Parisa [GetSet-India] @ 2007-12-06 07:14 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Hi Kris,
No Luck with that!
My Test java program look like this
------------
try{
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();
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());
}
--------------------------
and SP look like
===========
CREATE OR REPLACE FUNCTION test_function()
RETURNS int4 AS
$BODY$
declare
begin
raise notice 'testing the Stored proc%','SP Tested';
return 1;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION test_function() OWNER TO postgres;
========================
The results when i run the java program are:
intUpdates length==>>1
i number is==>>0
i value is==>>0
test size===>>[0]
which shows the SP is not getting executed for all the times??
please suggest.
On Dec 5, 2007 9:32 PM, Kranti K K Parisa [GetSet-India] <
kranti.parisa@gmail.com> wrote:
> excellent. let me try and update you
>
> thanks!
>
>
> On Dec 5, 2007 9:26 PM, Kris Jurka <books@ejurka.com> wrote:
>
> >
> >
> > On Wed, 5 Dec 2007, Kranti K K Parisa [GetSet-India] wrote:
> >
> > > We are using Postgres 8.1 version. Does this mean we need to upgrade
> > the
> > > database version also? or can use the driver with latest release?
> > >
> >
> > You can use the 8.3 driver with any server version >= 7.2.
> >
> > Kris Jurka
> >
>
>
>
> --
> ------------------
> Best Regards
> Kranti Kiran Kumar Parisa
> Mobile: +91 - 9849 - 625 - 625
> +91 - 9391 - 438 - 738
>
--
------------------
Best Regards
Kranti Kiran Kumar Parisa
Mobile: +91 - 9849 - 625 - 625
+91 - 9391 - 438 - 738
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-06 09:39 Kris Jurka <books@ejurka.com>
parent: Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kris Jurka @ 2007-12-06 09:39 UTC (permalink / raw)
To: Kranti K K Parisa \[GetSet-India\] <kranti.parisa@gmail.com>; +Cc: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-06 09:42 Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 8+ messages in thread
From: Kranti K K Parisa [GetSet-India] @ 2007-12-06 09:42 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: 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
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BatchUpdate exception
@ 2007-12-06 09:47 Kris Jurka <books@ejurka.com>
parent: Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
0 siblings, 0 replies; 8+ messages in thread
From: Kris Jurka @ 2007-12-06 09:47 UTC (permalink / raw)
To: Kranti K K Parisa \[GetSet-India\] <kranti.parisa@gmail.com>; +Cc: pgsql-jdbc
On Thu, 6 Dec 2007, Kranti K K Parisa [GetSet-India] wrote:
> 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++){
> for(int j=0;j<4;j++){
> proc=con.prepareCall("{call test_function()}");
You're still doing the exact same thing, initializing proc inside the
loop. You need to do this once outside the loops.
Kris Jurka
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2007-12-06 09:47 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-12-05 14:24 BatchUpdate exception Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
2007-12-05 15:36 ` Kris Jurka <books@ejurka.com>
2007-12-05 15:52 ` Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
2007-12-05 15:56 ` Kris Jurka <books@ejurka.com>
2007-12-06 07:14 ` Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
2007-12-06 09:39 ` Kris Jurka <books@ejurka.com>
2007-12-06 09:42 ` Kranti K K Parisa [GetSet-India] <kranti.parisa@gmail.com>
2007-12-06 09:47 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox