Re: PreparedStatement.executeBatch() error? 7.3 - Mailing list pgsql-jdbc

From Jeremiah Jahn
Subject Re: PreparedStatement.executeBatch() error? 7.3
Date
Msg-id 1044892256.1851.531.camel@bluejay.goodinassociates.com
Whole thread Raw
In response to Re: PreparedStatement.executeBatch() error? 7.3  (Barry Lind <blind@xythos.com>)
Responses Re: PreparedStatement.executeBatch() error? 7.3  (Barry Lind <blind@xythos.com>)
List pgsql-jdbc
Here are the results of the log level set to 2. There seems to be a
little extra data stuck on the end of the batch version.


 Establishing connection...PostgreSQL 7.3b1 JDBC3 jdbc driver build 104
LOG:  query: set datestyle to 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN'
elsegetdatabaseencoding() end; 
getConnection returning driver[className=org.postgresql.Driver,org.postgresql.Driver@5dd582]
done
LOG:  query: begin;
LOG:  query: delete from actor where case_id = '1998CF46' and court_ori = 'IL078015J'
...
LOG:  query: insert into case_data (case_id,court_ori,extraction_datetime,update_date) values
('1998CF46','IL078015J','20030210T092429','1901/01/01')
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)
        at com.goodinassociates.judici.importer.judici.DOXImporter.importDoc(Unknown Source)
        at com.goodinassociates.judici.importer.judici.ImportServer$Client.run(ImportServer.java:482)
LOG:  query: insert into case_data_store values ('1998CF46','IL078015J',0,'\\254\\355\\000\\005t\\001\\245<?xml
version="1.0"encoding="UTF-8"?>\\015\\012<!DOCTYPE CourtDataTransferFile>\\015\\012<CourtDataTransferFile
FileCreationDateTime="20030210T092429"Version="1"><Provider ProducerID="translation" ID="GAL" /><Court
NCIC="IL078015J"><CaseNumber="1998CF46" Action="Delete" ModificationType="None" LastUpdateDate="1901/01/01" TypeCode=""
SubtypeCode=""TypeSubtypeText="" Year="" Title="" Category=""
/></Court></CourtDataTransferFile>\\015\\012')'1998CF46'Qrollback;begin; 
ERROR:  parser: parse error at or near "'1998CF46'" at character 541

the last line looks like this in the non-batch version:
LOG:  query: insert into case_data_store values ('1998CF47','IL078015J',0,'\\254\\355\\000\\005t\\001\\245<?xml
version="1.0"encoding="UTF-8"?>\\015\\012<!DOCTYPE CourtDataTransferFile>\\015\\012<CourtDataTransferFile
FileCreationDateTime="20030210T093214"Version="1"><Provider ProducerID="translation" ID="GAL" /><Court
NCIC="IL078015J"><CaseNumber="1998CF47" Action="Delete" ModificationType="None" LastUpdateDate="1901/01/01" TypeCode=""
SubtypeCode=""TypeSubtypeText="" Year="" Title="" Category="" /></Court></CourtDataTransferFile>\\015\\012') 

There is no '1998CF46' stuff tagged on the end of it.



On Fri, 2003-02-07 at 21:34, Barry Lind wrote:
> Jeremiah,
>
> I am a bit confused.  You mention two different errors in your email the
>   "ERROR:  parser:...." and the stack trace.  Do both get produced at
> the same time, or are they happening at different times?
>
> Also the parse error looks like an error coming from the database.  Can
> you turn on query logging on the server to see the text of the statement
> that the error is occuring in?  That should provide a clue as to why the
> sql statement is invalid.
>
> To log the sql statements on the server you want to set the parameter
> log_statement=true in your postgresql.conf file.  Also it might help to
> turn on debug logging in the jdbc driver.  Can you add ?loglevel=2 to
> the jdbc connection url?  (both of the above suggestions are for 7.3,
> the details on doing this on 7.2 are a bit different).
>
> thanks,
> --Barry
>
>
> Jeremiah Jahn wrote:
> > 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)
> >
> >
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Jeremiah Jahn <jeremiah@cs.earlham.edu>


pgsql-jdbc by date:

Previous
From: Holger Klawitter
Date:
Subject: omitted line in errors.properties (7.3.2)
Next
From: Dave Cramer
Date:
Subject: Re: java.lang.ClassNotFoundException loading JDBC driver