Subject Fw: sql error processing problem
Author William Surowiec
I sent this 2 days ago and it appears the electrons bonded somewhere
along the way. So, at the risk of repetition, here it is again.


----- Original Message -----
From: "William Surowiec" <wsurowiec@...>
To: <IB-Java@yahoogroups.com>
Sent: Thursday, January 31, 2002 10:32 PM
Subject: sql error processing problem


I was getting a sql error, that in processing the error was getting

java.lang.ArrayIndexOutOfBoundsException


that was happening around

at org.firebirdsql.gds.GDSExceptionHelper$GDSMessage.toString
(GDSExceptionHelper.java:136)

(ignore the exact line number, I've already played with the code)

When I made the following 2 changes (marked with //<==== INSERTED):


public String toString() {
String message = template;
for(int i = 0; i < params.length; i++) {
String param = "{" + i + "}";
int pos = message.indexOf(param);
if (pos > -1) { //<====
INSERTED
String temp = message.substring(0, pos);
temp += (params[i] == null) ? "" : params[i];
temp += message.substring(pos + param.length());
message = temp;
} //<====
INSERTED
}
return message;
}


I then get to see the sql error:

insert: patient sql failed java.sql.SQLException:
GDS exception:
attempt to store duplicate value (visible to active transactions)
in unique index {1}

The sql error is obviously mine, but I'm not sure what the right code
should
be in GDSExceptionHelper.java

I'm using a cvs update that says (for .../gds/GDSExceptionHelper.java):

/*
* CVS modification log:
* $Log: GDSExceptionHelper.java,v $
* Revision 1.4 2002/01/07 06:59:54 d_jencks
* Revised FBManager to create dialect 3 databases, and the tests to use
a newly created database. Simplified and unified test constants. Test
targets are now all-tests for all tests and one-test for one test:
specify the test as -Dtest=Gds one-test for the TestGds.class test.
Made a few other small changes to improve error messages
*


Bill