Skip site navigation (1) Skip section navigation (2)

Re: executeBatch() issue with new driver?

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: stange(at)rentec(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: executeBatch() issue with new driver?
Date: 2004-11-02 17:24:32
Message-ID: 4187C2D0.5050708@fastcrypt.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Well, I'm not suggesting that this is the intent of the driver, just 
pointing out that there is an inference in the documentation that the 
API may not be intended to be used that way.

Dave

Alan Stange wrote:

> Dave Cramer wrote:
>
>> Without looking at the code, I noticed that the javadoc's refer to 
>> addBatch as adding a single command, see below.
>>
>> Adds the given SQL command to the current list of commmands for this 
>> |Statement| object. The commands in this list can be executed as a 
>> batch by calling the method |executeBatch|.
>
>
> I see.
> This appears to be a change in behavior from the pg74 drivers, which 
> do accept more than a single statement.   The MS SQLServer JDBC 
> driver  also accepts more than one statement.
>
> I was leaning toward dropping our use of batches anyway.  Thanks.
>
> -- Alan
>
>
>> Alan Stange wrote:
>>
>>> Hello all,
>>>
>>> I'm using pg8 beta 3, with the pgdev.307.jdbc3.jar JDBC driver.
>>>
>>>
>>> If I run the following example code:
>>>
>>> Connection conn = ...;
>>> Statement st = conn.createStatement();
>>> String sql = "create temp table t (a int4); insert into t (a) values 
>>> (1);";
>>> st.addBatch(sql);
>>> st.executeBatch();
>>>
>>> I get the following error:
>>>
>>> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
>>>    at 
>>> org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2317) 
>>>
>>>    at 
>>> org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleCommandStatus(AbstractJdbc2Statement.java:2293) 
>>>
>>>    at 
>>> org.postgresql.core.v3.QueryExecutorImpl.interpretCommandStatus(QueryExecutorImpl.java:1230) 
>>>
>>>    at 
>>> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:968) 
>>>
>>>    at 
>>> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283) 
>>>
>>>    at 
>>> org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2371) 
>>>
>>>    at com.rentec.fi.db.DbStatement.executeBatch(DbStatement.java:88)
>>>
>>>
>>> Am I missing something here?
>>>
>>> Thanks!
>>>
>>> -- Alan
>>>
>>> ---------------------------(end of 
>>> broadcast)---------------------------
>>> TIP 2: you can get off all lists at once with the unregister command
>>>    (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>>>
>>>
>>
>
>
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561


In response to

Responses

pgsql-jdbc by date

Next:From: Alan StangeDate: 2004-11-02 17:33:41
Subject: Re: executeBatch() issue with new driver?
Previous:From: Alan StangeDate: 2004-11-02 17:05:34
Subject: Re: executeBatch() issue with new driver?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group