From: | Jeremiah Jahn <jeremiah(at)cs(dot)earlham(dot)edu> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | PreparedStatement.executeBatch() error? 7.3 |
Date: | 2003-02-07 22:01:22 |
Message-ID: | 1044655282.1848.506.camel@bluejay.goodinassociates.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
The following code doesn't work, but if in place of doing an addBatch
loop with an executeBatch(), I do an executeUpdate each time it does
work. I get a parse error from the db server:
ERROR: parser: parse error at or near "'1998CF43'" at character 4202
this corresponds to the first value. I'm using the jdbc3 jar for this.
PreparedStatement pStatement = connection.prepareStatement("insert into case_data_store values (?,?,?,?)");
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
for (int current_chunk = 0; current_chunk < chunk_count; current_chunk++){
pStatement.setString(1,values.get("CASENUMBER").toString());
pStatement.setString(2,values.get("NCIC").toString());
pStatement.setInt(3,current_chunk);
pStatement.setBytes(4,baos.toByteArray());
pStatement.addBatch();
//pStatement.executeUpdate();
}
pStatement.executeBatch();
This is the stack trace:
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:143)
at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:65)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:451)
at
org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:281)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:179)
at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:165)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:80)
--
Jeremiah Jahn <jeremiah(at)cs(dot)earlham(dot)edu>
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2003-02-08 02:47:18 | Re: patch for COPY |
Previous Message | Michael Adler | 2003-02-07 21:56:58 | patch for COPY |