Have a look at the following code fragment:
try {
query = "CREATE TABLE MYTABLE(MYFIELD INTEGER NOT NULL PRIMARY KEY)";
stmt.executeUpdate(query);
} catch (SQLException sex) {
System.out.println("Could not create table!");
}
Two questions:
1. If the table already exists, Interbase should thrown an exception, and my
catch statement should handle it. Oddly, Interbase does seem to thrown an
exception (or at least try), but the catch statement doesn't catch it! I get
the following on the JAVA console, instead of my message:
"Exception in thread "main" java.lang.VerifyError: (class:
interbase/interclient/ErrorKey, method: _$372 signature:
(Ljava/lang/String;Ljava/lang/String;I)V) Expecting to find unitialized
object on stack
at interbase.interclient.SQLException.<init>(SQLException.java:96)
at
interbase.interclient.RecvMessage.createSQLException(RecvMessage.java:694)
at
interbase.interclient.RecvMessage.makeSQLException(RecvMessage.java:593)
at
interbase.interclient.RecvMessage.get_EXCEPTIONS(RecvMessage.java:554)
at interbase.interclient.Statement._$121578(Statement.java:282)
at interbase.interclient.Statement.executeUpdate(Statement.java:261)
2. What I am trying to accomplish is, if a table doesn't already exists,
create it at the start of my program. As I couldn't find any command that
would tell me if a table exists or not, my idea was to create the table
anyway, and catch any exception that will occur if the table already
existed. Is this a good way of doing this, or is there a more solid
approach?
Thanks!
Koen
--
PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced positions
for people who want to work with Java, XML, SOAP and E-Commerce infrastructure products.
We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose CA.
Send resumes to j...@bea.com