Subject Exception preparing statement
Author Kenneth Foo
Hi

I have this exception being thrown ...

java.lang.ArrayIndexOutOfBoundsException: 2
at org.firebirdsql.jgds.GDS_Impl.isc_vax_integer(GDS_Impl.java:1300)
at org.firebirdsql.jgds.GDS_Impl.parseTruncSqlInfo(GDS_Impl.java:1901)
at org.firebirdsql.jgds.GDS_Impl.parseSqlInfo(GDS_Impl.java:1873)
at org.firebirdsql.jgds.GDS_Impl.isc_dsql_prepare(GDS_Impl.java:1163)
at
org.firebirdsql.jca.FBManagedConnection.prepareSQL(FBManagedConnection.java:
767)
at org.firebirdsql.jdbc.FBConnection.prepareSQL(FBConnection.java:1107)
at
org.firebirdsql.jdbc.FBStatement.prepareFixedStatement(FBStatement.java:942)
at
org.firebirdsql.jdbc.FBPreparedStatement.prepareFixedStatement(FBPreparedSta
tement.java:699)
at org.firebirdsql.jdbc.FBPreparedStatement.(FBPreparedStatement.java:78)
at
org.firebirdsql.jdbc.FBConnection.prepareStatement(FBConnection.java:243)
at com.nic.sql.ConnectionEx.prepareStatement(ConnectionEx.java:214)
at com.nic.connect.db.MessageDB.getMessageHeaders(MessageDB.java:2385)
at com.nic.connect.ContextImpl.getMessageHeaders(ContextImpl.java:637)
... 38 more



Line 2385 of MessageDB.java is my code below (fails at preparestatement)

private static String _retrieveRecordFields =

"FOLDER_ID,REFERENCE_ID,EXTERNAL_REF,MSG_TYPE,MSG_CLS,MSG_FROM,MSG_TO,MSG_CC
," +
"MSG_SUBJECT,MSG_SIZE,COMMENTS,ACCOUNT_ID,COMPOSE_DURATION," +
"SEND_TIME,PRIORITY,CREATE_TIME," +

"READ_TIME,REPLY_TIME,APPROVE_FLAG,FLAG_TIME,WATCH_FLAG,TOPICS,URGENCY,MOVE_
TIME,REASON,INCIDENT_ID ";

Record rec = null;
Connection con = _pool.getConnection();
final String sql = "SELECT " + _retrieveRecordFields + " FROM
MESSAGES WHERE ID=?;";
PreparedStatement ps = null;
try {
con.setAutoCommit(false);
ps = con.prepareStatement(sql); ///////LINE 2385 IS HERE
ArrayList list = new ArrayList(500);
for (int i=0; i<msgids.length; i++) {

...


My table metadata goes something like this

CREATE TABLE "MESSAGES"
(
"ID" INT64 NOT NULL,
"FOLDER_ID" INT64,
"REFERENCE_ID" INT64,
"EXTERNAL_REF" VARCHAR(80) CHARACTER SET UNICODE_FSS,
"MSG_TYPE" SMALLINT,
"MSG_CLS" VARCHAR(40) CHARACTER SET UNICODE_FSS,
"MSG_FROM" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ASCII,
"MSG_TO" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ASCII,
"MSG_CC" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET ASCII,
"MSG_SUBJECT" VARCHAR(200) CHARACTER SET UNICODE_FSS,
"MSG_SIZE" INTEGER,
"HEADER_DATA" BLOB SUB_TYPE TEXT SEGMENT SIZE 1024 CHARACTER SET ASCII,
"COMMENTS" BLOB SUB_TYPE TEXT SEGMENT SIZE 200 CHARACTER SET ASCII,
"ACCOUNT_ID" VARCHAR(22) CHARACTER SET UNICODE_FSS,
"COMPOSE_DURATION" INTEGER,
"PRIORITY" SMALLINT,
"URGENCY" INT64,
"CREATE_TIME" TIMESTAMP,
"READ_TIME" TIMESTAMP,
"REPLY_TIME" TIMESTAMP,
"FORWARD_TIME" TIMESTAMP,
"FLAG_FLAG" SMALLINT NOT NULL,
"APPROVE_FLAG" SMALLINT NOT NULL,
"WATCH_FLAG" SMALLINT NOT NULL,
"COMPLETE_FLAG" SMALLINT NOT NULL,
"TEXT_CONTENT" BLOB SUB_TYPE TEXT SEGMENT SIZE 1024 CHARACTER SET ASCII,
"HTML_CONTENT" BLOB SUB_TYPE TEXT SEGMENT SIZE 1024 CHARACTER SET ASCII,
"KEYWORDS" BLOB SUB_TYPE TEXT SEGMENT SIZE 1024 CHARACTER SET ASCII,
"TOPICS" BLOB SUB_TYPE TEXT SEGMENT SIZE 1024 CHARACTER SET ASCII,
"MIME_CONTENT" BLOB SUB_TYPE TEXT SEGMENT SIZE 4096 CHARACTER SET ASCII,
"SEND_TIME" TIMESTAMP,
"REASON" BLOB SUB_TYPE TEXT SEGMENT SIZE 80 CHARACTER SET UNICODE_FSS,
"MOVE_TIME" TIMESTAMP,
"FLAG_TIME" TIMESTAMP,
"ORIGINAL_FOLDER_ID" INT64,
"TRANSFER_TIME" TIMESTAMP,
"INCIDENT_ID" INT64,
PRIMARY KEY ("ID")
);