Java JDBC Database Metadata tableExists(String tableName, Connection conn)

Here you can find the source of tableExists(String tableName, Connection conn)

Description

table Exists

License

Open Source License

Declaration

public static boolean tableExists(String tableName, Connection conn) throws SQLException 

Method Source Code


//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 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;
            }/*from   w w w.jav  a2s.c om*/
        }
        return false;
    }
}

Related

  1. sequenceExists(String seqName, Connection conn)
  2. tableExists(Connection con, String table)
  3. tableExists(Connection connection, String tableName)
  4. tableExists(Connection connection, String tableName)
  5. tableExists(DatabaseMetaData metaData, String tableName)
  6. tableExists(String tableName, DatabaseMetaData dbm)
  7. tableIsAccesable(Connection conn, String TableName)