Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Checking if table exists

843854Aug 21 2002 — edited Aug 21 2002
I found a query on 4GuysFromRolla to check if a table exists on SQL Server 2000, and then execute a query. Here's my code:

String sql_query = "if EXISTS (select * from INFORMATION_SCHEMA.tables where table_name = '" + table_name + "') Select * from " + table_name;
ResultSet rs = stmt.executeQuery(sql_query);
while (rs.next()) {
....
}


Now I know for a fact that the table doesn't exist, but instead of getting nothing, I get a "No ResultSet was produced" error. Is there any way around this?

Dan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 18 2002
Added on Aug 21 2002
2 comments
824 views