X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 322699DCC1C for ; Sun, 26 Feb 2006 19:59:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93738-04 for ; Sun, 26 Feb 2006 19:59:30 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 8B1779DCC00 for ; Sun, 26 Feb 2006 19:59:25 -0400 (AST) Received: from cartman.kenetworks.se (unknown [213.80.66.91]) by svr4.postgresql.org (Postfix) with ESMTP id 202FC5AF180 for ; Sun, 26 Feb 2006 23:59:28 +0000 (GMT) Received: from plyschmanxp (localhost.localdomain [127.0.0.1]) by cartman.kenetworks.se (Postfix) with ESMTP id A43B67EFF73 for ; Mon, 27 Feb 2006 00:59:52 +0100 (CET) Message-ID: <00d101c63b30$aa7a2b40$635a59d5@plyschmanxp> From: =?iso-8859-1?Q?Bj=F6rn_Bergenheim?= To: Subject: How to get batch commands to work Date: Mon, 27 Feb 2006 00:59:22 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00CE_01C63B39.0BE63A10" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200602/170 X-Sequence-Number: 14767 This is a multi-part message in MIME format. ------=_NextPart_000_00CE_01C63B39.0BE63A10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello all, I have tried to check out the archive since this seems like a = question I shouldnt be the first to ask, but I have come up with = nothing. I'm doing a massive insert batch, and thought that you could = add a few insert to a batch, and then execute the batch, and then = continue adding more inserts, and then run the batch, and so on. = However, when I try to do this, I get an exception when I try to = populate my prepared statement after I have run the executeBatch() for = the first time. The eception I get is "Parameter index out of range": Caused by: Parameter index out of range. at = org.postgresql.jdbc1.AbstractJdbc1Statement.bind(AbstractJdbc1Statement.j= ava:1743) at = org.postgresql.jdbc1.AbstractJdbc1Statement.setInt(AbstractJdbc1Statement= .java:782) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at = sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java= :39) at = sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI= mpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at = org.postgresql.ds.common.PooledConnectionImpl$StatementHandler.invoke(Poo= ledConnectionImpl.java:467) at $Proxy2.setInt(Unknown Source) at = com.frontvision.nemo2.utilities.hostip.Importer.insertCountries(Importer.= java:287) at = com.frontvision.nemo2.utilities.hostip.Importer.read(Importer.java:216) ... 15 more I have a pstmt which I use, and in a loop adds stuff to it like this: pstmt.setInt(1,countryId); pstmt.setString(2, countryName); pstmt.setString(3, shortContryName); pstmt.addBatch(); then after say 200 of these batches, I do a=20 if(counter%200 =3D 0) { pstmt.executeBatch(); } and then continue to add to the batch. Have I got this completly wrong, = ei is this not the correct way to do it, or is there something fishy = with my db or jdcb drivers? I'm using win8.0 version and jdbc = 8.0-314,jdbc3.jar=20 /Bjorn ------=_NextPart_000_00CE_01C63B39.0BE63A10 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello all, I have tried to check out = the archive=20 since this seems like a question I shouldnt be the first to ask, but I = have come=20 up with nothing. I'm doing a massive insert batch, and thought that you = could=20 add a few insert to a batch, and then execute the batch, and then = continue=20 adding more inserts, and then run the batch, and so on. However, when I = try to=20 do this, I get an exception when I try to populate my prepared statement = after I=20 have run the executeBatch() for the first time. The eception I get is = "Parameter=20 index out of range":
 
Caused by: Parameter index out of=20 range.
 at=20 org.postgresql.jdbc1.AbstractJdbc1Statement.bind(AbstractJdbc1Statement.j= ava:1743)
 at=20 org.postgresql.jdbc1.AbstractJdbc1Statement.setInt(AbstractJdbc1Statement= .java:782)
 at=20 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at=20 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java= :39)
 at=20 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI= mpl.java:25)
 at=20 java.lang.reflect.Method.invoke(Method.java:585)
 at=20 org.postgresql.ds.common.PooledConnectionImpl$StatementHandler.invoke(Poo= ledConnectionImpl.java:467)
 at=20 $Proxy2.setInt(Unknown Source)
 at=20 com.frontvision.nemo2.utilities.hostip.Importer.insertCountries(Importer.= java:287)
 at=20 com.frontvision.nemo2.utilities.hostip.Importer.read(Importer.java:216) ...=20 15 more
 
I have a pstmt which I use, and in a = loop adds=20 stuff to it like this:
   =20 pstmt.setInt(1,countryId);
   pstmt.setString(2,=20 countryName);
   pstmt.setString(3,=20 shortContryName);
   pstmt.addBatch();
 
then after say 200 of these batches, I = do a=20
if(counter%200 =3D 0)
{
   =20 pstmt.executeBatch();
}
and then continue to add to the batch. = Have I got=20 this completly wrong, ei is this not the correct way to do it, or is = there=20 something fishy with my db or jdcb drivers? I'm using win8.0 version and = jdbc=20 8.0-314,jdbc3.jar
 
/Bjorn
------=_NextPart_000_00CE_01C63B39.0BE63A10--