Example usage for java.sql Types TIME

List of usage examples for java.sql Types TIME

Introduction

In this page you can find the example usage for java.sql Types TIME.

Prototype

int TIME

To view the source code for java.sql Types TIME.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIME.

Usage

From source file:CreateNewTable.java

private static Vector getDataTypes(Connection con) throws SQLException {
    String structName = null, distinctName = null, javaName = null;

    // create a vector of class DataType initialized with
    // the SQL code, the SQL type name, and two null entries
    // for the local type name and the creation parameter(s)

    Vector dataTypes = new Vector();
    dataTypes.add(new DataType(java.sql.Types.BIT, "BIT"));
    dataTypes.add(new DataType(java.sql.Types.TINYINT, "TINYINT"));
    dataTypes.add(new DataType(java.sql.Types.SMALLINT, "SMALLINT"));
    dataTypes.add(new DataType(java.sql.Types.INTEGER, "INTEGER"));
    dataTypes.add(new DataType(java.sql.Types.BIGINT, "BIGINT"));
    dataTypes.add(new DataType(java.sql.Types.FLOAT, "FLOAT"));
    dataTypes.add(new DataType(java.sql.Types.REAL, "REAL"));
    dataTypes.add(new DataType(java.sql.Types.DOUBLE, "DOUBLE"));
    dataTypes.add(new DataType(java.sql.Types.NUMERIC, "NUMERIC"));
    dataTypes.add(new DataType(java.sql.Types.DECIMAL, "DECIMAL"));
    dataTypes.add(new DataType(java.sql.Types.CHAR, "CHAR"));
    dataTypes.add(new DataType(java.sql.Types.VARCHAR, "VARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARCHAR, "LONGVARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.DATE, "DATE"));
    dataTypes.add(new DataType(java.sql.Types.TIME, "TIME"));
    dataTypes.add(new DataType(java.sql.Types.TIMESTAMP, "TIMESTAMP"));
    dataTypes.add(new DataType(java.sql.Types.BINARY, "BINARY"));
    dataTypes.add(new DataType(java.sql.Types.VARBINARY, "VARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARBINARY, "LONGVARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.NULL, "NULL"));
    dataTypes.add(new DataType(java.sql.Types.OTHER, "OTHER"));
    dataTypes.add(new DataType(java.sql.Types.BLOB, "BLOB"));
    dataTypes.add(new DataType(java.sql.Types.CLOB, "CLOB"));

    DatabaseMetaData dbmd = con.getMetaData();
    ResultSet rs = dbmd.getTypeInfo();
    while (rs.next()) {
        int codeNumber = rs.getInt("DATA_TYPE");
        String dbmsName = rs.getString("TYPE_NAME");
        String createParams = rs.getString("CREATE_PARAMS");

        if (codeNumber == Types.STRUCT && structName == null)
            structName = dbmsName;/*from ww  w . j a  va  2 s  .c o m*/
        else if (codeNumber == Types.DISTINCT && distinctName == null)
            distinctName = dbmsName;
        else if (codeNumber == Types.JAVA_OBJECT && javaName == null)
            javaName = dbmsName;
        else {
            for (int i = 0; i < dataTypes.size(); i++) {
                // find entry that matches the SQL code, 
                // and if local type and params are not already set,
                // set them
                DataType type = (DataType) dataTypes.get(i);
                if (type.getCode() == codeNumber) {
                    type.setLocalTypeAndParams(dbmsName, createParams);
                }
            }
        }
    }

    int[] types = { Types.STRUCT, Types.DISTINCT, Types.JAVA_OBJECT };
    rs = dbmd.getUDTs(null, "%", "%", types);
    while (rs.next()) {
        String typeName = null;
        DataType dataType = null;

        if (dbmd.isCatalogAtStart())
            typeName = rs.getString(1) + dbmd.getCatalogSeparator() + rs.getString(2) + "." + rs.getString(3);
        else
            typeName = rs.getString(2) + "." + rs.getString(3) + dbmd.getCatalogSeparator() + rs.getString(1);

        switch (rs.getInt(5)) {
        case Types.STRUCT:
            dataType = new DataType(Types.STRUCT, typeName);
            dataType.setLocalTypeAndParams(structName, null);
            break;
        case Types.DISTINCT:
            dataType = new DataType(Types.DISTINCT, typeName);
            dataType.setLocalTypeAndParams(distinctName, null);
            break;
        case Types.JAVA_OBJECT:
            dataType = new DataType(Types.JAVA_OBJECT, typeName);
            dataType.setLocalTypeAndParams(javaName, null);
            break;
        }
        dataTypes.add(dataType);
    }

    return dataTypes;
}

From source file:Main.java

private static Vector getDataTypes(Connection con) throws SQLException {
    String structName = null, distinctName = null, javaName = null;

    // create a vector of class DataType initialized with
    // the SQL code, the SQL type name, and two null entries
    // for the local type name and the creation parameter(s)

    Vector dataTypes = new Vector();
    dataTypes.add(new DataType(java.sql.Types.BIT, "BIT"));
    dataTypes.add(new DataType(java.sql.Types.TINYINT, "TINYINT"));
    dataTypes.add(new DataType(java.sql.Types.SMALLINT, "SMALLINT"));
    dataTypes.add(new DataType(java.sql.Types.INTEGER, "INTEGER"));
    dataTypes.add(new DataType(java.sql.Types.BIGINT, "BIGINT"));
    dataTypes.add(new DataType(java.sql.Types.FLOAT, "FLOAT"));
    dataTypes.add(new DataType(java.sql.Types.REAL, "REAL"));
    dataTypes.add(new DataType(java.sql.Types.DOUBLE, "DOUBLE"));
    dataTypes.add(new DataType(java.sql.Types.NUMERIC, "NUMERIC"));
    dataTypes.add(new DataType(java.sql.Types.DECIMAL, "DECIMAL"));
    dataTypes.add(new DataType(java.sql.Types.CHAR, "CHAR"));
    dataTypes.add(new DataType(java.sql.Types.VARCHAR, "VARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARCHAR, "LONGVARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.DATE, "DATE"));
    dataTypes.add(new DataType(java.sql.Types.TIME, "TIME"));
    dataTypes.add(new DataType(java.sql.Types.TIMESTAMP, "TIMESTAMP"));
    dataTypes.add(new DataType(java.sql.Types.BINARY, "BINARY"));
    dataTypes.add(new DataType(java.sql.Types.VARBINARY, "VARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARBINARY, "LONGVARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.NULL, "NULL"));
    dataTypes.add(new DataType(java.sql.Types.OTHER, "OTHER"));
    dataTypes.add(new DataType(java.sql.Types.BLOB, "BLOB"));
    dataTypes.add(new DataType(java.sql.Types.CLOB, "CLOB"));

    DatabaseMetaData dbmd = con.getMetaData();
    ResultSet rs = dbmd.getTypeInfo();
    while (rs.next()) {
        int codeNumber = rs.getInt("DATA_TYPE");
        String dbmsName = rs.getString("TYPE_NAME");
        String createParams = rs.getString("CREATE_PARAMS");

        if (codeNumber == Types.STRUCT && structName == null)
            structName = dbmsName;// w w w.j ava 2s  . c  om
        else if (codeNumber == Types.DISTINCT && distinctName == null)
            distinctName = dbmsName;
        else if (codeNumber == Types.JAVA_OBJECT && javaName == null)
            javaName = dbmsName;
        else {
            for (int i = 0; i < dataTypes.size(); i++) {
                // find entry that matches the SQL code,
                // and if local type and params are not already set,
                // set them
                DataType type = (DataType) dataTypes.get(i);
                if (type.getCode() == codeNumber) {
                    type.setLocalTypeAndParams(dbmsName, createParams);
                }
            }
        }
    }

    int[] types = { Types.STRUCT, Types.DISTINCT, Types.JAVA_OBJECT };
    rs = dbmd.getUDTs(null, "%", "%", types);
    while (rs.next()) {
        String typeName = null;
        DataType dataType = null;

        if (dbmd.isCatalogAtStart())
            typeName = rs.getString(1) + dbmd.getCatalogSeparator() + rs.getString(2) + "." + rs.getString(3);
        else
            typeName = rs.getString(2) + "." + rs.getString(3) + dbmd.getCatalogSeparator() + rs.getString(1);

        switch (rs.getInt(5)) {
        case Types.STRUCT:
            dataType = new DataType(Types.STRUCT, typeName);
            dataType.setLocalTypeAndParams(structName, null);
            break;
        case Types.DISTINCT:
            dataType = new DataType(Types.DISTINCT, typeName);
            dataType.setLocalTypeAndParams(distinctName, null);
            break;
        case Types.JAVA_OBJECT:
            dataType = new DataType(Types.JAVA_OBJECT, typeName);
            dataType.setLocalTypeAndParams(javaName, null);
            break;
        }
        dataTypes.add(dataType);
    }

    return dataTypes;
}

From source file:org.dashbuilder.dataprovider.sql.JDBCUtils.java

public static ColumnType calculateType(int sqlDataType) {
    switch (sqlDataType) {

    // Category-like columns.
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.BIT:
    case Types.BOOLEAN: {
        return ColumnType.LABEL;
    }/*from ww w  .  j  a v a2s  . c o m*/

    // Text-like columns.
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR: {
        return ColumnType.TEXT;
    }

    // Number-like columns.
    case Types.TINYINT:
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.NUMERIC:
    case Types.REAL:
    case Types.SMALLINT: {
        return ColumnType.NUMBER;
    }

    // Date-like columns.
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP: {
        return ColumnType.DATE;
    }

    // Unsupported
    default: {
        return null;
    }
    }
}

From source file:CSVWriter.java

private static String getColumnValue(ResultSet rs, int colType, int colIndex)
    throws SQLException, IOException {

  String value = "";
      /*w ww  .j  ava 2 s  . co m*/
switch (colType)
{
  case Types.BIT:
    Object bit = rs.getObject(colIndex);
    if (bit != null) {
      value = String.valueOf(bit);
    }
  break;
  case Types.BOOLEAN:
    boolean b = rs.getBoolean(colIndex);
    if (!rs.wasNull()) {
      value = Boolean.valueOf(b).toString();
    }
  break;
  case Types.CLOB:
    Clob c = rs.getClob(colIndex);
    if (c != null) {
      value = read(c);
    }
  break;
  case Types.BIGINT:
  case Types.DECIMAL:
  case Types.DOUBLE:
  case Types.FLOAT:
  case Types.REAL:
  case Types.NUMERIC:
    BigDecimal bd = rs.getBigDecimal(colIndex);
    if (bd != null) {
      value = "" + bd.doubleValue();
    }
  break;
  case Types.INTEGER:
  case Types.TINYINT:
  case Types.SMALLINT:
    int intValue = rs.getInt(colIndex);
    if (!rs.wasNull()) {
      value = "" + intValue;
    }
  break;
  case Types.JAVA_OBJECT:
    Object obj = rs.getObject(colIndex);
    if (obj != null) {
      value = String.valueOf(obj);
    }
  break;
  case Types.DATE:
    java.sql.Date date = rs.getDate(colIndex);
    if (date != null) {
      value = DATE_FORMATTER.format(date);;
    }
  break;
  case Types.TIME:
    Time t = rs.getTime(colIndex);
    if (t != null) {
      value = t.toString();
    }
  break;
  case Types.TIMESTAMP:
    Timestamp tstamp = rs.getTimestamp(colIndex);
    if (tstamp != null) {
      value = TIMESTAMP_FORMATTER.format(tstamp);
    }
  break;
  case Types.LONGVARCHAR:
  case Types.VARCHAR:
  case Types.CHAR:
    value = rs.getString(colIndex);
  break;
  default:
    value = "";
}

    
if (value == null)
{
  value = "";
}
    
return value;
      
}

From source file:org.apache.sqoop.tool.ImportTool.java

/**
 * Return the max value in the incremental-import test column. This
 * value must be numeric.// ww w.jav  a  2s . co m
 */
private Object getMaxColumnId(SqoopOptions options) throws SQLException {
    StringBuilder sb = new StringBuilder();
    String query;

    sb.append("SELECT MAX(");
    sb.append(options.getIncrementalTestColumn());
    sb.append(") FROM ");

    if (options.getTableName() != null) {
        // Table import
        sb.append(options.getTableName());

        String where = options.getWhereClause();
        if (null != where) {
            sb.append(" WHERE ");
            sb.append(where);
        }
        query = sb.toString();
    } else {
        // Free form table based import
        sb.append("(");
        sb.append(options.getSqlQuery());
        sb.append(") sqoop_import_query_alias");

        query = sb.toString().replaceAll("\\$CONDITIONS", "(1 = 1)");
    }

    Connection conn = manager.getConnection();
    Statement s = null;
    ResultSet rs = null;
    try {
        LOG.info("Maximal id query for free form incremental import: " + query);
        s = conn.createStatement();
        rs = s.executeQuery(query);
        if (!rs.next()) {
            // This probably means the table is empty.
            LOG.warn("Unexpected: empty results for max value query?");
            return null;
        }

        ResultSetMetaData rsmd = rs.getMetaData();
        checkColumnType = rsmd.getColumnType(1);
        if (checkColumnType == Types.TIMESTAMP) {
            return rs.getTimestamp(1);
        } else if (checkColumnType == Types.DATE) {
            return rs.getDate(1);
        } else if (checkColumnType == Types.TIME) {
            return rs.getTime(1);
        } else {
            return rs.getObject(1);
        }
    } finally {
        try {
            if (null != rs) {
                rs.close();
            }
        } catch (SQLException sqlE) {
            LOG.warn("SQL Exception closing resultset: " + sqlE);
        }

        try {
            if (null != s) {
                s.close();
            }
        } catch (SQLException sqlE) {
            LOG.warn("SQL Exception closing statement: " + sqlE);
        }
    }
}

From source file:net.riezebos.thoth.configuration.persistence.dbs.DDLExecuter.java

private void initDialect(DatabaseIdiom idiom) {
    databaseIdiom = idiom;/*from  www.ja  v  a 2 s . c om*/
    try {
        addTranslation("bigint", idiom.getTypeName(Types.BIGINT));
        addTranslation("binary", idiom.getTypeName(Types.BINARY));
        addTranslation("bit", idiom.getTypeName(Types.BIT));
        addTranslation("blob", idiom.getTypeName(Types.BLOB));
        addTranslation("boolean", idiom.getTypeName(Types.BOOLEAN));
        addTranslation("char", idiom.getTypeName(Types.CHAR));
        addTranslation("clob", idiom.getTypeName(Types.CLOB));
        addTranslation("date", idiom.getTypeName(Types.DATE));
        addTranslation("decimal", idiom.getTypeName(Types.DECIMAL));
        addTranslation("double", idiom.getTypeName(Types.DOUBLE));
        addTranslation("float", idiom.getTypeName(Types.FLOAT));
        addTranslation("integer", idiom.getTypeName(Types.INTEGER));
        addTranslation("longnvarchar", idiom.getTypeName(Types.LONGNVARCHAR));
        addTranslation("longvarbinary", idiom.getTypeName(Types.LONGVARBINARY));
        addTranslation("longvarchar", idiom.getTypeName(Types.LONGVARCHAR));
        addTranslation("nchar", idiom.getTypeName(Types.NCHAR));
        addTranslation("nclob", idiom.getTypeName(Types.NCLOB));
        addTranslation("numeric", idiom.getTypeName(Types.NUMERIC));
        addTranslation("nvarchar", idiom.getTypeName(Types.NVARCHAR));
        addTranslation("real", idiom.getTypeName(Types.REAL));
        addTranslation("smallint", idiom.getTypeName(Types.SMALLINT));
        addTranslation("time", idiom.getTypeName(Types.TIME));
        addTranslation("timestamp", idiom.getTypeName(Types.TIMESTAMP));
        addTranslation("tinyint", idiom.getTypeName(Types.TINYINT));
        addTranslation("varbinary", idiom.getTypeName(Types.VARBINARY));

        databaseIdiom.initDialect(translations, workarounds);
        // Ignore autogenerated ID's
        addWorkaround("generated always as identity", "");
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:org.apache.syncope.core.persistence.jpa.content.XMLContentExporter.java

private String getValues(final ResultSet rs, final String columnName, final Integer columnType)
        throws SQLException {

    String res = null;/*w  w  w  .  ja v a  2s .co m*/

    try {
        switch (columnType) {
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            final InputStream is = rs.getBinaryStream(columnName);
            if (is != null) {
                res = DatatypeConverter.printHexBinary(IOUtils.toByteArray(is));
            }
            break;

        case Types.BLOB:
            final Blob blob = rs.getBlob(columnName);
            if (blob != null) {
                res = DatatypeConverter.printHexBinary(IOUtils.toByteArray(blob.getBinaryStream()));
            }
            break;

        case Types.BIT:
        case Types.BOOLEAN:
            if (rs.getBoolean(columnName)) {
                res = "1";
            } else {
                res = "0";
            }
            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            final Timestamp timestamp = rs.getTimestamp(columnName);
            if (timestamp != null) {
                res = FormatUtils.format(new Date(timestamp.getTime()));
            }
            break;

        default:
            res = rs.getString(columnName);
        }
    } catch (IOException e) {
        LOG.error("Error retrieving hexadecimal string", e);
    }

    return res;
}

From source file:CreateNewType.java

private static Vector getDataTypes(Connection con, String typeToCreate) throws SQLException {
    String structName = null, distinctName = null, javaName = null;

    // create a vector of class DataType initialized with
    // the SQL code, the SQL type name, and two null entries
    // for the local type name and the creation parameter(s)

    Vector dataTypes = new Vector();
    dataTypes.add(new DataType(java.sql.Types.BIT, "BIT"));
    dataTypes.add(new DataType(java.sql.Types.TINYINT, "TINYINT"));
    dataTypes.add(new DataType(java.sql.Types.SMALLINT, "SMALLINT"));
    dataTypes.add(new DataType(java.sql.Types.INTEGER, "INTEGER"));
    dataTypes.add(new DataType(java.sql.Types.BIGINT, "BIGINT"));
    dataTypes.add(new DataType(java.sql.Types.FLOAT, "FLOAT"));
    dataTypes.add(new DataType(java.sql.Types.REAL, "REAL"));
    dataTypes.add(new DataType(java.sql.Types.DOUBLE, "DOUBLE"));
    dataTypes.add(new DataType(java.sql.Types.NUMERIC, "NUMERIC"));
    dataTypes.add(new DataType(java.sql.Types.DECIMAL, "DECIMAL"));
    dataTypes.add(new DataType(java.sql.Types.CHAR, "CHAR"));
    dataTypes.add(new DataType(java.sql.Types.VARCHAR, "VARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARCHAR, "LONGVARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.DATE, "DATE"));
    dataTypes.add(new DataType(java.sql.Types.TIME, "TIME"));
    dataTypes.add(new DataType(java.sql.Types.TIMESTAMP, "TIMESTAMP"));
    dataTypes.add(new DataType(java.sql.Types.BINARY, "BINARY"));
    dataTypes.add(new DataType(java.sql.Types.VARBINARY, "VARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARBINARY, "LONGVARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.NULL, "NULL"));
    dataTypes.add(new DataType(java.sql.Types.OTHER, "OTHER"));
    dataTypes.add(new DataType(java.sql.Types.BLOB, "BLOB"));
    dataTypes.add(new DataType(java.sql.Types.CLOB, "CLOB"));

    DatabaseMetaData dbmd = con.getMetaData();
    ResultSet rs = dbmd.getTypeInfo();
    while (rs.next()) {
        int codeNumber = rs.getInt("DATA_TYPE");
        String dbmsName = rs.getString("TYPE_NAME");
        String createParams = rs.getString("CREATE_PARAMS");

        if (codeNumber == Types.STRUCT && structName == null)
            structName = dbmsName;//from ww w. j a v a  2 s  .co  m
        else if (codeNumber == Types.DISTINCT && distinctName == null)
            distinctName = dbmsName;
        else if (codeNumber == Types.JAVA_OBJECT && javaName == null)
            javaName = dbmsName;
        else {
            for (int i = 0; i < dataTypes.size(); i++) {
                // find entry that matches the SQL code, 
                // and if local type and params are not already set,
                // set them
                DataType type = (DataType) dataTypes.get(i);
                if (type.getCode() == codeNumber) {
                    type.setLocalTypeAndParams(dbmsName, createParams);
                }
            }
        }
    }

    if (typeToCreate.equals("s")) {
        int[] types = { Types.STRUCT, Types.DISTINCT, Types.JAVA_OBJECT };
        rs = dbmd.getUDTs(null, "%", "%", types);
        while (rs.next()) {
            String typeName = null;
            DataType dataType = null;

            if (dbmd.isCatalogAtStart())
                typeName = rs.getString(1) + dbmd.getCatalogSeparator() + rs.getString(2) + "."
                        + rs.getString(3);
            else
                typeName = rs.getString(2) + "." + rs.getString(3) + dbmd.getCatalogSeparator()
                        + rs.getString(1);

            switch (rs.getInt(5)) {
            case Types.STRUCT:
                dataType = new DataType(Types.STRUCT, typeName);
                dataType.setLocalTypeAndParams(structName, null);
                break;
            case Types.DISTINCT:
                dataType = new DataType(Types.DISTINCT, typeName);
                dataType.setLocalTypeAndParams(distinctName, null);
                break;
            case Types.JAVA_OBJECT:
                dataType = new DataType(Types.JAVA_OBJECT, typeName);
                dataType.setLocalTypeAndParams(javaName, null);
                break;
            }
            dataTypes.add(dataType);
        }
    }

    return dataTypes;
}

From source file:org.jasig.ssp.util.importer.job.validation.map.metadata.database.MapColumnMetadata.java

public Object convertValueToType(String columnValue, MapReference mapReference,
        DatabaseConstraintMapValidationContext validation) {
    Object propertyValue = null;/* w ww .  jav  a2 s  .  c o m*/
    String typeAsString = "";
    if (columnValue != null) {
        try {
            switch (javaSqlType) {
            case Types.BIGINT:
                typeAsString = "BIGINT";
                propertyValue = Long.parseLong(columnValue);
                break;
            case Types.INTEGER:
                typeAsString = "INTEGER";
                propertyValue = Integer.parseInt(columnValue);
                break;
            case Types.DECIMAL:
                typeAsString = "DECIMAL";
            case Types.DOUBLE:
                typeAsString = "DOUBLE";
            case Types.FLOAT:
                typeAsString = "FLOAT";
            case Types.NUMERIC:
                typeAsString = "NUMERIC";
                propertyValue = new BigDecimal(columnValue);
                break;

            case Types.DATE:
                typeAsString = "DATE";
                propertyValue = DateUtils.parseDateStrictly(columnValue, DATE_PATTERNS);
                break;
            case Types.TIMESTAMP:
                typeAsString = "TIMESTAMP";
                propertyValue = new java.sql.Timestamp(Long.getLong(columnValue));
                break;
            case Types.TIME:
                typeAsString = "TIME";
                propertyValue = new Time(DateUtils.parseDateStrictly(columnValue, TIME_PATTERNS).getTime());
                break;
            default:
                typeAsString = javaSqlType.toString();
                propertyValue = columnValue;
                break;

            }
        } catch (Exception exception) {
            validation.addViolation(new UnableToParseMapViolation(mapReference, columnValue, typeAsString));
            propertyValue = columnValue;
        }

    }
    return propertyValue;
}

From source file:org.castor.jdo.engine.SQLTypeInfos.java

/**
 * Get value from given ResultSet at given index with given SQL type.
 * //w  ww  .  java2 s .c  o m
 * @param rs The ResultSet to get the value from.
 * @param index The index of the value in the ResultSet.
 * @param sqlType The SQL type of the value.
 * @return The value.
 * @throws SQLException If a database access error occurs.
 */
public static Object getValue(final ResultSet rs, final int index, final int sqlType) throws SQLException {
    switch (sqlType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return rs.getString(index);
    case Types.DECIMAL:
    case Types.NUMERIC:
        return rs.getBigDecimal(index);
    case Types.INTEGER:
        int intVal = rs.getInt(index);
        return (rs.wasNull() ? null : new Integer(intVal));
    case Types.TIME:
        return rs.getTime(index, getCalendar());
    case Types.DATE:
        return rs.getDate(index);
    case Types.TIMESTAMP:
        return rs.getTimestamp(index, getCalendar());
    case Types.FLOAT:
    case Types.DOUBLE:
        double doubleVal = rs.getDouble(index);
        return (rs.wasNull() ? null : new Double(doubleVal));
    case Types.REAL:
        float floatVal = rs.getFloat(index);
        return (rs.wasNull() ? null : new Float(floatVal));
    case Types.SMALLINT:
        short shortVal = rs.getShort(index);
        return (rs.wasNull() ? null : new Short(shortVal));
    case Types.TINYINT:
        byte byteVal = rs.getByte(index);
        return (rs.wasNull() ? null : new Byte(byteVal));
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
    case Types.BINARY:
        return rs.getBytes(index);
    case Types.BLOB:
        Blob blob = rs.getBlob(index);
        return (blob == null ? null : blob.getBinaryStream());
    case Types.CLOB:
        return rs.getClob(index);
    case Types.BIGINT:
        long longVal = rs.getLong(index);
        return (rs.wasNull() ? null : new Long(longVal));
    case Types.BIT:
        boolean boolVal = rs.getBoolean(index);
        return (rs.wasNull() ? null : new Boolean(boolVal));
    default:
        Object value = rs.getObject(index);
        return (rs.wasNull() ? null : value);
    }
}