Method 1,
Java. SQL. Connection con = getyourconnection ();
Resultset rs = con. getmetadata (). gettables (null, null, "yourtable", null );
If (Rs. Next ()){
// Yourtable exist
} Else {
// Yourtable not exist
}
Method 2,
Connection conn = NULL;
Databasemetadata dbmd = NULL;
Resultset rs = NULL;
Try {
Conn = getconnectionsource ();
Dbmd = conn. getmetadata ();
Rs = dbmd. gettables (null, new string [] {"table "});
While (Rs. Next ()){
String tablename = Rs. getstring ("table_name ");
System. Out. println ("tablename:" + tablename );
}
} Catch (exception ex ){
Throw ex;
} Finally {
Closeconnection (Conn, RS, null );
}
Dbmd. gettables (null, new string [] {"table"}); this is the key. You can view the Java API description for details. Method 1, the second sentence can be combined to write dbmd. gettables (null, null, tablename, new string [] {"table)