Subject | Re: [Firebird-Java] Re: PreparedStatements - bug in handling exception |
---|---|
Author | Miroslav Novak |
Post date | 2004-04-26T13:29:07Z |
Hi.
I have yet another a problem with the prepared statement and string
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.
The database is created by isql:
CREATE DATABASE '127.0.0.1:testdb';
CREATE TABLE tab (id integer, vc varchar(5));
INSERT INTO tab VALUES (1, 'a');
And the java code is:
import java.sql.*;
class TestJdbc {
static String databaseUrl = "jdbc:firebirdsql://127.0.0.1/testdb";
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection conn = DriverManager.getConnection(databaseUrl, "SYSDBA", "masterkey");
conn.setAutoCommit(false);
PreparedStatement prepstmt = conn.prepareStatement("UPDATE tab SET vc=? WHERE id = 1");
prepstmt.setString(1, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
try {
prepstmt.execute();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("-----------");
try {
conn.rollback();
} catch (Exception e) {
e.printStackTrace();
}
prepstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Mirek.
I have yet another a problem with the prepared statement and string
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.
The database is created by isql:
CREATE DATABASE '127.0.0.1:testdb';
CREATE TABLE tab (id integer, vc varchar(5));
INSERT INTO tab VALUES (1, 'a');
And the java code is:
import java.sql.*;
class TestJdbc {
static String databaseUrl = "jdbc:firebirdsql://127.0.0.1/testdb";
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection conn = DriverManager.getConnection(databaseUrl, "SYSDBA", "masterkey");
conn.setAutoCommit(false);
PreparedStatement prepstmt = conn.prepareStatement("UPDATE tab SET vc=? WHERE id = 1");
prepstmt.setString(1, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
try {
prepstmt.execute();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("-----------");
try {
conn.rollback();
} catch (Exception e) {
e.printStackTrace();
}
prepstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Mirek.
On Thu, 8 Apr 2004, Roman Rokytskyy wrote:
> > The error below occurs when a parameter is too big when used with
> > JayBird1.5b3. If I try it with FirebirdSQL1.0.1 I get a data
> > truncation error which at least is a lot easier to understand what
> > the problem is.
> >
> > There should be an understandable error message.
>
> Yes, this is a known problem. DataTruncationException was thrown in
> driver internally. However, there is one "feature" related to system
> tables and to make it work, we removed length checks in driver and let
> server do this. Unfortunately server instead of string truncation
> error reports "operation cancelled". I will check if we can solve it
> somehow.
>
> It would be great if you can fill it as either bug or feature request
> for JayBird.
>
> Roman
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>