Subject | Re: [Firebird-Java] Possible bug in batch updates |
---|---|
Author | Elias Holman |
Post date | 2004-07-19T13:22:30Z |
On Fri, 2004-07-16 at 20:06, Roman Rokytskyy wrote:
the problem. Here is my new test case:
Connection c = DriverManager.
getConnection("jdbc:firebirdsql:localhost:/testdbs/test1.fdb",
"username", "password");
Statement s = c.createStatement();
s.executeUpdate("CREATE TABLE foo (bar varchar(64) NOT NULL, baz
varchar(8) NOT NULL, CONSTRAINT pk_foo PRIMARY KEY (bar, baz))");
PreparedStatement ps = c.prepareStatement("Insert into foo values (?,
?)");
ps.setString(1, "one");
ps.setString(2, "two");
ps.addBatch();
ps.executeBatch();
ps.clearBatch();
ps.setString(1, "one");
ps.setString(2, "three");
ps.addBatch();
ps.executeBatch();
ps.clearBatch();
I get the same violation of primary key constraint pk_foo on the second
executeBatch(). Maybe the problem is in clearBatch()? Hope this helps.
--
Eli
> Hi,Unfortunately, I've added a ps.clearBatch() call, and it does not fix
>
> > ...
> > That final ps.executeBatch() throws a GDS Exception: 335544665, a
> > primary key violation. Removing the first executeBatch fixes the
> > problem, as does simply calling executeUpdate() instead of
> > addBatch() executeBatch() each time, which is why I believe it is a
> > problem with batching. Please let me know if I can provide more
> > info.
>
> Thanks for the report. This is a bug in driver - driver does not clear batch
> list after the batch execution. I will fix it tomorrow. Until the new
> version is released, please add clearBatch() call after the executeBatch()
> call.
the problem. Here is my new test case:
Connection c = DriverManager.
getConnection("jdbc:firebirdsql:localhost:/testdbs/test1.fdb",
"username", "password");
Statement s = c.createStatement();
s.executeUpdate("CREATE TABLE foo (bar varchar(64) NOT NULL, baz
varchar(8) NOT NULL, CONSTRAINT pk_foo PRIMARY KEY (bar, baz))");
PreparedStatement ps = c.prepareStatement("Insert into foo values (?,
?)");
ps.setString(1, "one");
ps.setString(2, "two");
ps.addBatch();
ps.executeBatch();
ps.clearBatch();
ps.setString(1, "one");
ps.setString(2, "three");
ps.addBatch();
ps.executeBatch();
ps.clearBatch();
I get the same violation of primary key constraint pk_foo on the second
executeBatch(). Maybe the problem is in clearBatch()? Hope this helps.
--
Eli