Java Utililty Methods SQL Type

List of utility methods to do SQL Type

Description

The list of methods to do SQL Type are organized into topic(s).

Method

ClassgetReturnClass(String typeName)
get Return Class
Class result = null;
if (typeName.equalsIgnoreCase("long")) {
    result = long.class;
} else if (typeName.equalsIgnoreCase("int")) {
    result = int.class;
} else if (typeName.equalsIgnoreCase("integer")) {
    result = Integer.class;
} else if (typeName.equalsIgnoreCase("short")) {
...
StringgetSemestre(Integer actionformation_id, Connection connection, String actionformation_libellecourt)
get Semestre
String semestre = "";
String theQuery = "SELECT structures_id,typestructure_id " + "FROM actionstructure "
        + "NATURAL JOIN structures " + "WHERE actionformation_id=" + actionformation_id;
try {
    System.out.println("Executing : " + theQuery);
    Statement theStmt = connection.createStatement();
    ResultSet theRS1 = theStmt.executeQuery(theQuery);
    while (theRS1.next()) {
...
StringgetSerialPrimaryKeyTypeString(Connection conn)
get Serial Primary Key Type String
String dbms = conn.getMetaData().getDatabaseProductName();
if (SQLSERVER.equalsIgnoreCase(dbms))
    return "BIGINT PRIMARY KEY IDENTITY";
if (ORACLE.equalsIgnoreCase(dbms))
    return ORACLE_SERIAL_TYPE;
return "SERIAL PRIMARY KEY";
StringgetSimpleTypeString(String dbType)
get Simple Type String
if (dbType.startsWith("int")) {
    return "int";
} else if (dbType.startsWith("double")) {
    return "double";
} else if (dbType.startsWith("char")) {
    return "String";
} else if (dbType.startsWith("varchar")) {
    return "String";
...
ClassgetSQLAttributeType(int sqlType)
Convert database type to connector supported set of attribute types Can be redefined for different databases
Class<?> ret;
switch (sqlType) {
case Types.DECIMAL:
case Types.NUMERIC:
    ret = BigDecimal.class;
    break;
case Types.DOUBLE:
    ret = Double.class;
...
SQLExceptiongetSQLException(String message, String sqlState, Exception exception)
Returns a SQLException and sets the initCause if running with a 1.4+ JVM.
return getSQLException(message, sqlState, Integer.MIN_VALUE, exception);
StringgetSQLParameterSubstring(String value, int type)
get SQL Parameter Substring
if (isNumericType(type)) {
    return value;
} else {
    return "'" + value + "'";
StringgetSqlType(int type)
Gets the sqlType attribute of the FBUtils class
switch (type) {
case Types.ARRAY:
    return "ARRAY ";
case Types.BIGINT:
    return "BIGINT ";
case Types.BINARY:
    return "BINARY";
case Types.BIT:
...
intgetSqlType(Object param)
Returns SQL type matches the object.
int type;
if (param == null) {
    type = Types.NULL;
} else {
    if (param instanceof String)
        type = Types.VARCHAR;
    else if (param instanceof Integer)
        type = Types.INTEGER;
...
intgetSqlType(String cubridType)
get the java.sql type map to cubrid data type.
if (cubridType == null || cubridType.trim().equals("")) {
    return Types.VARCHAR;
cubridType = cubridType.toUpperCase();
if (cubridType.equals("CHAR")) {
    return Types.CHAR;
} else if (cubridType.equals("VARCHAR")) {
    return Types.VARCHAR;
...