Detect if a table exists
import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; public class Main { public static void main(String[] argv) throws Exception { Connection c = null; DatabaseMetaData dbm = c.getMetaData(); ResultSet rs = dbm.getTables(null, null, "employee", null); if (rs.next()) { System.out.println("Table exists"); } else { System.out.println("Table does not exist"); } } }