Kathey Marsden wrote:
alternately you can use the DatabaseMetaData to see if the table is there
I don't know if this is still the case, but Derby could only do that in a transaction so make sure you call conn.setAutoCommit(false) before.
   DatabaseMetaData dmd = conn.getMetaData();
   ResultSet rs = dmd.getTables(null,"APP", "FOO",null);
If you just want the table (not views or system tables), you should specify it using:
ResultSet rs = dmd.getTables(null,"APP", "FOO", new String[]{"TABLE"});
   if (!rs.next()) {
       s.executeUpdate("CREATE TABLE FOO (I INT)");
   }
This is probably the cleanest method especially if you want this DDL statement to be part of a larger transaction, not triggering exception in the middle is usually much better.

Hope this helps,
Emmanuel

--
Emmanuel Cecchet
FTO @ Frog Thinker Open Source Development & Consulting
--
Web: http://www.frogthinker.org
email: [email protected]
Skype: emmanuel_cecchet

Reply via email to