Subject | Re: PreparedStatements - bug in handling exception |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-04-26T21:10Z |
Hi,
version from CVS (basically RC2 with one fix that will appear in RC3)
and could not reproduce it. Did you try your test case with RC2? Can
you check out JayBird from CVS and check if my version of the test
case is correct (TestFBPreparedStatement.testLongParameter()). Here's
its text:
/**
* Test if parameters are correctly checked for their length.
* @throws Exception if something went wrong.
*/
public void testLongParameter() throws Exception {
con.setAutoCommit(true);
Statement stmt = con.createStatement();
try {
stmt.execute("INSERT INTO testtab(id, field1, field6)
VALUES(1, '', 'a')");
} finally {
stmt.close();
}
con.setAutoCommit(false);
PreparedStatement ps =
con.prepareStatement("UPDATE testtab SET field6=? WHERE id
= 1");
try {
try {
ps.setString(1,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
ps.execute();
con.commit();
} catch(SQLException ex) {
con.rollback();
}
} catch(SQLException ex) {
ex.printStackTrace();
fail("No exception should be thrown.");
} finally {
ps.close();
}
}
Thanks!
Roman
> I have yet another a problem with the prepared statement and stringI tried your test case (though I modified it a bit) with recent
> truncation. When I execute prepared statement where the text is
> longer than the field length it throws exception operation
> cancelled, as explained in this thread, but then I tried to rollback
> the transaction and I got "GDS Exception. 335544726. Error reading
> data from the connection."
> The connection seems to be broken now on.
> This was at my Windows box. On Linux it just doesn't throw the first
> excepion about the cancellation of the operation, but just the Error
> reading data from the connection.
> I am using Jaybird for JDK 1.4.
version from CVS (basically RC2 with one fix that will appear in RC3)
and could not reproduce it. Did you try your test case with RC2? Can
you check out JayBird from CVS and check if my version of the test
case is correct (TestFBPreparedStatement.testLongParameter()). Here's
its text:
/**
* Test if parameters are correctly checked for their length.
* @throws Exception if something went wrong.
*/
public void testLongParameter() throws Exception {
con.setAutoCommit(true);
Statement stmt = con.createStatement();
try {
stmt.execute("INSERT INTO testtab(id, field1, field6)
VALUES(1, '', 'a')");
} finally {
stmt.close();
}
con.setAutoCommit(false);
PreparedStatement ps =
con.prepareStatement("UPDATE testtab SET field6=? WHERE id
= 1");
try {
try {
ps.setString(1,
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
ps.execute();
con.commit();
} catch(SQLException ex) {
con.rollback();
}
} catch(SQLException ex) {
ex.printStackTrace();
fail("No exception should be thrown.");
} finally {
ps.close();
}
}
Thanks!
Roman