Java SQL Table hasTable(String TableName, Connection conn)

Here you can find the source of hasTable(String TableName, Connection conn)

Description

has Table

License

Apache License

Declaration

public static boolean hasTable(String TableName, Connection conn) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.*;

public class Main {
    public static boolean hasTable(String TableName, Connection conn) throws SQLException {
        DatabaseMetaData md = conn.getMetaData();
        String[] Types = { "TABLE", "VIEW" };
        ResultSet rs = md.getTables(null, null, TableName, null);
        boolean ret = rs.next();
        rs.close();//from ww w.  j a  v  a  2s.co m
        if (ret)
            return (ret);

        rs = md.getTables(null, null, TableName.toUpperCase(), null);
        ret = rs.next();
        rs.close();
        return (ret);
    }
}

Related

  1. getTablesFromDatabase(Connection conn)
  2. getTableSize(Connection conn, String tableName)
  3. getTableSize(final Statement statement, final String schema, final String table, boolean scope)
  4. getTotalRows(String tableName, Statement statement)
  5. hasTable(Connection conn, String schemaName, String tableName)
  6. isExistsDerbyTable(Connection derbyConnection, String schema, String table)
  7. isFileImportable(File file, String prefix)
  8. isTableEmpty(Connection con, String schemaName, String tableName)
  9. normalizeTableName(String table, Connection con)