Subject Problem using curly brackets in VARCHARS
Author Marcus Rau
Hello,

I'm encountering some kind of strange behaviour while using JayBird (1.4
and 1.5, java 1.4 versions!) with FB 1.5.1 (database settings: default
settings for encoding and page size, using SQL Dialect 3). It seems that
JayBird can't handle VARCHARS containing '{' or '}'.

Assume there's a table containing the following columns:

* MY_ID, INTEGER
* MY_TITLE, VARCHAR(256)
* MY_DATE, TIMESTAMP

Inserting a simple row into that table can't be done, if one tries to
store a value in MY_TITLE containing curly brackets.

Following code produces (Win XP, j2sdk 1.4.2_10) the error:

public static void main(String[] args) {
try{
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection con =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:C:/MDDB.FDB",
"TESTUSER", "testpwd");

String sql="INSERT INTO mytable VALUES(21, '{TEST}', {ts '2005-11-18
09:02:21.677'})";

// HERE'S the problem!! Connection.nativeSQL(...)
// produces a DAMAGED STATEMENT ...
sql = con.nativeSQL(sql);

// ... as you can see, if you look at the generated output!!!
System.out.println(sql);

PreparedStatement statement=con.prepareStatement(sql);
statement.execute();
con.close();

}
catch(Exception e){
e.printStackTrace();
}
}

Invoking Connection.nativeSQL(...) produces the following output (in
quotes):

"INSERT INTO mytable VALUES(21, '{Test}',"

As you can see, this statement is not complete. Apparantly, the denoted
timestamp has not been processed correctly. Doing the same stuff without
using curly brackets in the field to be stored as VARCHAR behaves quite
well. So, in some situation, it seems to be critical, to mix characters
and JDBC-like masked time information.

By the way: The stack trace looks like this:

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic
SQL Error
SQL error code = -104
Unexpected end of command
at
org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:118)
at
org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:40)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:849)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:812)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:805)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:286)
at DBTEST.DatabaseTester.main(DatabaseTester.java:31)
at org.firebirdsql.gds.GDSException: Dynamic SQL Error
SQL error code = -104
Unexpected end of command
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2104)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2054)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlPrepare(AbstractJavaGDSImpl.java:1478)
at org.firebirdsql.gds.impl.GDSHelper.prepareStatement(GDSHelper.java:194)
at
org.firebirdsql.jdbc.AbstractStatement.prepareFixedStatement(AbstractStatement.java:1107)
at
org.firebirdsql.jdbc.AbstractPreparedStatement.prepareFixedStatement(AbstractPreparedStatement.java:1145)
at
org.firebirdsql.jdbc.AbstractPreparedStatement.<init>(AbstractPreparedStatement.java:116)
at
org.firebirdsql.jdbc.FBPreparedStatement.<init>(FBPreparedStatement.java:40)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:849)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:812)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:805)
at
org.firebirdsql.jdbc.AbstractConnection.prepareStatement(AbstractConnection.java:286)
at DBTEST.DatabaseTester.main(DatabaseTester.java:31)

Can anybody tell me, what the problem really is??? Is there a need to
mask curly brackets in any way? How can I avoid the problem (or at least
bypass it)?

Sincerely
Marcus