aspose file tools
The moose likes JDBC and the fly likes how to test if table exists Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "how to test if table exists" Watch "how to test if table exists" New topic
Author

how to test if table exists

David Gilmore
Greenhorn

Joined: Jul 19, 2002
Posts: 9
I'm writing a database tools application and a portion of my code depends on whether or not a table exists in the database. Is there any way i can test for this? I have not been able to find any methods in the API.


There are 10 types of people in this world - those who understand binary and those who don't.
Tanel Alumae
Greenhorn

Joined: Aug 26, 2002
Posts: 14
Hello,
There are numerous methods in the DatabaseMetaData inteface for querying for existing tables, schemas, stored procedures, etc.
If the jdbc driver of your database doesn't support it, you can use a direct SQL query on the database metadata (e.g. "select table_name from user_tables" in Oracle) but then you lose portability.
Hope this helps.


RefactorIT - Java Refactoring Tool<br /><a href="http://www.refactorit.com" target="_blank" rel="nofollow">www.refactorit.com</a>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to test if table exists
 
Similar Threads
CHECK IF A TABLE ALREADY EXISTS
Java & MS Access
Check existence of table
Exception when having different class and table name
Check if a table exists in a database