Hi,
I tried to implement your code and it compiles without errors.
String[] names = { "TABLE" };
ResultSet result;
DatabaseMetaData metadata = null;
try {
metadata = dbConnection.getMetaData();
result = metadata.getTables(null, null, null, names);
while((result.next()) & (tableExists = false)) {
System.out.println(result.getString("TABLE_NAME"));
}
} catch(java.sql.SQLException e) {
e.printStackTrace();
}
This should print ever table in the db but although there are three
tables (tabelle1, tabelle2, tabelle3) in the database nothing is in
the output.
Any ideas?
Thanks Wolf
Am 03.10.2007 um 14:26 schrieb Mikael:
You can only use SQL queryes there, no special command line tools,
you could do something like this in JDBC:
DatabaseMetaData metadata = null;
metadata = connection.getMetaData();
String[] names = { "TABLE"};
ResultSet tableNames = metadata.getTables( null, null, null,
names);
while( tableNames.next())
{
String tab = tableNames.getString( "TABLE_NAME");
}
tab will contain the table name of each table it finds.....
Not sure if this helps you though....
----- Original Message ----- From: "Wolf Bublitz" <[EMAIL PROTECTED]
dortmund.de>
To: <[email protected]>
Sent: Wednesday, October 03, 2007 2:18 PM
Subject: checking if table exists
Hi,
I'm new to Derby DB and I want to know how it is possible to check
if a table exits. Via the command line tool I can get a list by
typing "SHOW TALBES" but in Netbeans' db-editor this does not work.
I get the following error:
SHOW TABLES
Error code 30000, SQL state 42X01: Syntaxfehler: Encountered
"SHOW" at line 1, column 1.
Line 1, column 1
Greetings Wolf