I am trying to perform a check on the database for a table using the below snippet: But the problem is, if the table or the view is empty the condition tables.next() does not evaluate to true, how to handle this scenario?
DatabaseMetaData dbm = con.getMetaData();
ResultSet tables = dbm.getTables(null, null, "your_table_name", null);
if (tables.next()) {
// Table exists
}
else {
// Table does not exist
}