Bug in sqlite-jdbc-3.6.4.1: Statement.executeBatch() does not clear command batch
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
MAILER-DAEMON <thenl... @gmail.com>
Date: Tue, 11 Nov 2008 05:18:26 -0800 (PST)
Local: Tues, Nov 11 2008 8:18 am
Subject: Bug in sqlite-jdbc-3.6.4.1: Statement.executeBatch() does not clear command batch
Hi,
I found the following code does not work as expected:
stat.executeUpdate("drop table if exists t;");
stat.executeUpdate("create table t (c text);");
prep = conn.prepareStatement("insert into t values (?);");
prep.setString(1, "a");
prep.addBatch();
System.out.println("call 1: " + prep.executeBatch().length);
prep.setString(1, "b");
prep.addBatch();
System.out.println("call 2: " + prep.executeBatch().length);
rs = stat.executeQuery("select * from t;");
while (rs.next())
System.out.println(rs.getString(1));
Output:
call 1: 1
call 2: 2
a
a
b
The expected result (and what I get with MySQL driver) would be:
call 1: 1
call 2: 1
a
b
That is, the call to executeBatch() should delete the commands in the
batch and not execute them again on the next call.
Regards,
Thomas.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Taro L. Saito" <l... @xerial.org>
Date: Sun, 16 Nov 2008 16:04:54 -0800 (PST)
Local: Sun, Nov 16 2008 7:04 pm
Subject: Re: Bug in sqlite-jdbc-3.6.4.1: Statement.executeBatch() does not clear command batch
Hi,
I am not sure which behavior is truely expected in the JDBC
specification:
http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec2/jdbc2.1.frame6.htm...
However, it seems that each call of executeBatch() method do the
updates
to the database, so the first result makes sense to me in that
it correctly returns the number of SQL queries executed.
<thenl
... @gmail.com> wrote:
> Hi,
> I found the following code does not work as expected:
> stat.executeUpdate("drop table if exists t;");
> stat.executeUpdate("create table t (c text);");
> prep = conn.prepareStatement("insert into t values (?);");
> prep.setString(1, "a");
> prep.addBatch();
> System.out.println("call 1: " + prep.executeBatch().length);
> prep.setString(1, "b");
> prep.addBatch();
> System.out.println("call 2: " + prep.executeBatch().length);
> rs = stat.executeQuery("select * from t;");
> while (rs.next())
> System.out.println(rs.getString(1));
> Output:
> call 1: 1
> call 2: 2
> a
> a
> b
> The expected result (and what I get with MySQL driver) would be:
> call 1: 1
> call 2: 1
> a
> b
> That is, the call to executeBatch() should delete the commands in the
> batch and not execute them again on the next call.
> Regards,
> Thomas.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Taro L. Saito" <l... @xerial.org>
Date: Sun, 16 Nov 2008 16:43:11 -0800 (PST)
Local: Sun, Nov 16 2008 7:43 pm
Subject: Re: Bug in sqlite-jdbc-3.6.4.1: Statement.executeBatch() does not clear command batch
Hi Thomas,
It seems that you are correct. I found the following part in the JDBC
document:
http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec2/jdbc2.1.frame6.htm...
- The statement's internal list of batch elements is reset to empty
once executeBatch() returns.
The executeBatch() method has to clear the internal list after the
execution.
However, I cannot find any description in JDBC API about the state of
the batch after the execution.. umm
http://java.sun.com/j2se/1.3/docs/api/java/sql/Statement.html#execute... ()
Anyway, I'd like to fix the bug, but I have no time to do this for a
couple of weeks..
Thanks for your report.
> Hi,
> I am not sure which behavior is truely expected in the JDBC
> specification:http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec2/jdbc2.1.frame6.htm ...
> However, it seems that each call of executeBatch() method do the
> updates
> to the database, so the first result makes sense to me in that
> it correctly returns the number of SQL queries executed.
> <thenl... @gmail.com> wrote:
> > Hi,
> > I found the following code does not work as expected:
> > stat.executeUpdate("drop table if exists t;");
> > stat.executeUpdate("create table t (c text);");
> > prep = conn.prepareStatement("insert into t values (?);");
> > prep.setString(1, "a");
> > prep.addBatch();
> > System.out.println("call 1: " + prep.executeBatch().length);
> > prep.setString(1, "b");
> > prep.addBatch();
> > System.out.println("call 2: " + prep.executeBatch().length);
> > rs = stat.executeQuery("select * from t;");
> > while (rs.next())
> > System.out.println(rs.getString(1));
> > Output:
> > call 1: 1
> > call 2: 2
> > a
> > a
> > b
> > The expected result (and what I get with MySQL driver) would be:
> > call 1: 1
> > call 2: 1
> > a
> > b
> > That is, the call to executeBatch() should delete the commands in the
> > batch and not execute them again on the next call.
> > Regards,
> > Thomas.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
julianbui <julian... @gmail.com>
Date: Mon, 8 Dec 2008 11:53:52 -0800 (PST)
Local: Mon, Dec 8 2008 2:53 pm
Subject: Re: Bug in sqlite-jdbc-3.6.4.1: Statement.executeBatch() does not clear command batch
Also found the same thing. I had to close the PS and create a new
one. This is slightly different than the other jdbc usages I've seen.
On Nov 11, 5:18 am, MAILER-DAEMON <thenl... @gmail.com> wrote:
> Hi,
> I found the following code does not work as expected:
> stat.executeUpdate("drop table if exists t;");
> stat.executeUpdate("create table t (c text);");
> prep = conn.prepareStatement("insert into t values (?);");
> prep.setString(1, "a");
> prep.addBatch();
> System.out.println("call 1: " + prep.executeBatch().length);
> prep.setString(1, "b");
> prep.addBatch();
> System.out.println("call 2: " + prep.executeBatch().length);
> rs = stat.executeQuery("select * from t;");
> while (rs.next())
> System.out.println(rs.getString(1));
> Output:
> call 1: 1
> call 2: 2
> a
> a
> b
> The expected result (and what I get with MySQL driver) would be:
> call 1: 1
> call 2: 1
> a
> b
> That is, the call to executeBatch() should delete the commands in the
> batch and not execute them again on the next call.
> Regards,
> Thomas.
You must
Sign in before you can post messages.
You do not have the permission required to post.