Here you can find the source of printTableExistence(String name, Connection conn)
public static void printTableExistence(String name, Connection conn) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; public class Main { public static void printTableExistence(String name, Connection conn) throws SQLException { if (tableExists(name, conn)) System.out.println(name + " exists"); else// w w w.j av a 2s.c om System.out.println(name + " does not exist"); } public static boolean tableExists(String tableName, Connection conn) throws SQLException { DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs = dbmd.getTables(null, null, null, null); while (rs.next()) { if (rs.getString("TABLE_NAME").equalsIgnoreCase(tableName)) { return true; } } return false; } }