Code example for DatabaseMetaData

Methods: getTables

0
	public static boolean doesTableExist(Connection connection, String tableName) throws SQLException { 
		 
		boolean tableExists = false;
		 
		DatabaseMetaData metaData = connection.getMetaData();
		ResultSet tablesList = metaData.getTables(null, null, tableName, null);
		 
		if(tablesList.next()) {
			tableExists = true;
		} 
		 
		tablesList.close();
		tablesList = null;
		 
		metaData = null;
		 
		return tableExists;
	} 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE