Java JDBC Database Metadata isIdGenerated(DatabaseMetaData metaData)

Here you can find the source of isIdGenerated(DatabaseMetaData metaData)

Description

is Id Generated

License

Apache License

Declaration

public static boolean isIdGenerated(DatabaseMetaData metaData) throws Exception 

Method Source Code

//package com.java2s;
/* Copyright 2009, 2011 predic8 GmbH, www.predic8.com
    // w w w  .ja v a 2  s. com
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License. */

import java.sql.DatabaseMetaData;

import java.sql.SQLException;

import java.util.regex.Pattern;

public class Main {
    public static boolean isIdGenerated(DatabaseMetaData metaData) throws Exception {
        return isDerbyDatabase(metaData) || isMySQLDatabase(metaData) || isOracleDatabase(metaData);
    }

    public static boolean isDerbyDatabase(DatabaseMetaData metaData) throws SQLException {
        return Pattern.matches(".*derby.*", metaData.getDatabaseProductName().toLowerCase());
    }

    public static boolean isMySQLDatabase(DatabaseMetaData metaData) throws SQLException {
        return Pattern.matches(".*mysql.*", metaData.getDatabaseProductName().toLowerCase());
    }

    public static boolean isOracleDatabase(DatabaseMetaData metaData) throws SQLException {
        return Pattern.matches(".*oracle.*", metaData.getDatabaseProductName().toLowerCase());
    }
}

Related

  1. getTableNames(Connection conn)
  2. getTableNames(DatabaseMetaData dbMD)
  3. isDB2(DatabaseMetaData metadata)
  4. isDerbyDatabase(DatabaseMetaData metaData)
  5. isExistsTable(Connection con, String schema, String tableName)
  6. isMysql(DatabaseMetaData metadata)
  7. isOracleForSid(DatabaseMetaData metadata, String oracleProduct)
  8. isSybase(DatabaseMetaData metadata)
  9. isSybaseDb(DatabaseMetaData metaData)