Java SQL Type getSerialPrimaryKeyTypeString(Connection conn)

Here you can find the source of getSerialPrimaryKeyTypeString(Connection conn)

Description

get Serial Primary Key Type String

License

Open Source License

Declaration

public static String getSerialPrimaryKeyTypeString(Connection conn) throws SQLException 

Method Source Code

//package com.java2s;
/*/*from  w  w  w.j  ava2  s. c  om*/
Weave (Web-based Analysis and Visualization Environment)
Copyright (C) 2008-2011 University of Massachusetts Lowell
    
This file is a part of Weave.
    
Weave is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, Version 3,
as published by the Free Software Foundation.
    
Weave is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Weave.  If not, see <http://www.gnu.org/licenses/>.
*/

import java.sql.Connection;

import java.sql.SQLException;

public class Main {
    public static String SQLSERVER = "Microsoft SQL Server";
    public static String ORACLE = "Oracle";
    public static String ORACLE_SERIAL_TYPE = "ORACLE_SERIAL_TYPE";

    public static String getSerialPrimaryKeyTypeString(Connection conn) throws SQLException {
        String dbms = conn.getMetaData().getDatabaseProductName();
        if (SQLSERVER.equalsIgnoreCase(dbms))
            return "BIGINT PRIMARY KEY IDENTITY";

        if (ORACLE.equalsIgnoreCase(dbms))
            return ORACLE_SERIAL_TYPE;

        // for mysql and postgresql, return the following.
        return "SERIAL PRIMARY KEY";
    }
}

Related

  1. getPreferredHibernateType(int sqlType, int size, int precision, int scale, boolean nullable, boolean generatedIdentifier)
  2. getPreparedStatementSetMethodMap()
  3. getPrimitiveInstance(Type type, String valueString)
  4. getReturnClass(String typeName)
  5. getSemestre(Integer actionformation_id, Connection connection, String actionformation_libellecourt)
  6. getSimpleTypeString(String dbType)
  7. getSQLAttributeType(int sqlType)
  8. getSQLException(String message, String sqlState, Exception exception)
  9. getSQLParameterSubstring(String value, int type)