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:org.wso2.carbon.dataservices.core.odata.RDBMSDataHandler.java

/**
 * This method bind values to prepared statement.
 *
 * @param type            data Type/*from w w  w  . j  av  a  2  s  . co  m*/
 * @param value           String value
 * @param ordinalPosition Ordinal Position
 * @param sqlStatement    Statement
 * @throws SQLException
 * @throws ParseException
 * @throws ODataServiceFault
 */
private void bindValuesToPreparedStatement(int type, String value, int ordinalPosition,
        PreparedStatement sqlStatement) throws SQLException, ParseException, ODataServiceFault {
    byte[] data;
    try {
        switch (type) {
        case Types.INTEGER:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setInt(ordinalPosition, ConverterUtil.convertToInt(value));
            }
            break;
        case Types.TINYINT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setByte(ordinalPosition, ConverterUtil.convertToByte(value));
            }
            break;
        case Types.SMALLINT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setShort(ordinalPosition, ConverterUtil.convertToShort(value));
            }
            break;
        case Types.DOUBLE:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setDouble(ordinalPosition, ConverterUtil.convertToDouble(value));
            }
            break;
        case Types.VARCHAR:
            /* fall through */
        case Types.CHAR:
            /* fall through */
        case Types.LONGVARCHAR:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setString(ordinalPosition, value);
            }
            break;
        case Types.CLOB:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setClob(ordinalPosition, new BufferedReader(new StringReader(value)),
                        value.length());
            }
            break;
        case Types.BOOLEAN:
            /* fall through */
        case Types.BIT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setBoolean(ordinalPosition, ConverterUtil.convertToBoolean(value));
            }
            break;
        case Types.BLOB:
            /* fall through */
        case Types.LONGVARBINARY:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                data = this.getBytesFromBase64String(value);
                sqlStatement.setBlob(ordinalPosition, new ByteArrayInputStream(data), data.length);
            }
            break;
        case Types.BINARY:
            /* fall through */
        case Types.VARBINARY:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                data = this.getBytesFromBase64String(value);
                sqlStatement.setBinaryStream(ordinalPosition, new ByteArrayInputStream(data), data.length);
            }
            break;
        case Types.DATE:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setDate(ordinalPosition, DBUtils.getDate(value));
            }
            break;
        case Types.DECIMAL:
            /* fall through */
        case Types.NUMERIC:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setBigDecimal(ordinalPosition, ConverterUtil.convertToBigDecimal(value));
            }
            break;
        case Types.FLOAT:
            /* fall through */
        case Types.REAL:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setFloat(ordinalPosition, ConverterUtil.convertToFloat(value));
            }
            break;
        case Types.TIME:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setTime(ordinalPosition, DBUtils.getTime(value));
            }
            break;
        case Types.LONGNVARCHAR:
            /* fall through */
        case Types.NCHAR:
            /* fall through */
        case Types.NVARCHAR:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setNString(ordinalPosition, value);
            }
            break;
        case Types.NCLOB:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setNClob(ordinalPosition, new BufferedReader(new StringReader(value)),
                        value.length());
            }
            break;
        case Types.BIGINT:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setLong(ordinalPosition, ConverterUtil.convertToLong(value));
            }
            break;
        case Types.TIMESTAMP:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setTimestamp(ordinalPosition, DBUtils.getTimestamp(value));
            }
            break;
        default:
            if (value == null) {
                sqlStatement.setNull(ordinalPosition, type);
            } else {
                sqlStatement.setString(ordinalPosition, value);
            }
            break;
        }
    } catch (DataServiceFault e) {
        throw new ODataServiceFault(e, "Error occurred while binding values. :" + e.getMessage());
    }
}

From source file:org.apache.openjpa.persistence.jdbc.XMLPersistenceMappingParser.java

/**
 * Extend to set the columns./* ww  w.j  av  a  2s. com*/
 */
@Override
protected void endFieldMapping(FieldMetaData field) throws SAXException {
    // setup columns with cached lob and temporal info
    FieldMapping fm = (FieldMapping) field;
    if (_lob || _temporal != null) {
        int typeCode = fm.isElementCollection() ? fm.getElement().getDeclaredTypeCode()
                : fm.getDeclaredTypeCode();
        Class<?> type = fm.isElementCollection() ? fm.getElement().getDeclaredType() : fm.getDeclaredType();
        if (_cols == null) {
            _cols = new ArrayList<Column>(1);
            _cols.add(new Column());
        }
        for (Column col : _cols) {
            if (_lob && (typeCode == JavaTypes.STRING || type == char[].class || type == Character[].class)) {
                col.setSize(-1);
                col.setType(Types.CLOB);
            } else if (_lob)
                col.setType(Types.BLOB);
            else {
                switch (_temporal) {
                case DATE:
                    col.setType(Types.DATE);
                    break;
                case TIME:
                    col.setType(Types.TIME);
                    break;
                case TIMESTAMP:
                    col.setType(Types.TIMESTAMP);
                    break;
                }
            }
        }
    }

    if (_cols != null) {
        switch (fm.getDeclaredTypeCode()) {
        case JavaTypes.ARRAY:
            Class<?> type = fm.getDeclaredType();
            if (type == byte[].class || type == Byte[].class || type == char[].class
                    || type == Character[].class) {
                fm.getValueInfo().setColumns(_cols);
                break;
            }
            // else no break
        case JavaTypes.COLLECTION:
            if (!fm.getValue().isSerialized()) {
                fm.getElementMapping().getValueInfo().setColumns(_cols);
            } else {
                fm.getValueInfo().setColumns(_cols);
            }
            break;
        case JavaTypes.MAP:
            fm.getElementMapping().getValueInfo().setColumns(_cols);
            break;
        default:
            fm.getValueInfo().setColumns(_cols);
        }
        if (_colTable != null)
            fm.getMappingInfo().setTableIdentifier(DBIdentifier.newTable(_colTable, delimit()));
        setUnique(fm);
    }
    clearColumnInfo();
}

From source file:org.executequery.databasemediators.spi.DefaultStatementExecutor.java

/** <p>Executes the specified procedure.
 *
 *  @param  the SQL procedure to execute
 *  @return the query result// ww  w.  j a  v  a  2 s  .  c o m
 */
public SqlStatementResult execute(DatabaseExecutable databaseExecutable) throws SQLException {

    if (!prepared()) {

        return statementResult;
    }

    ProcedureParameter[] param = databaseExecutable.getParametersArray();
    Arrays.sort(param, new ProcedureParameterSorter());

    String procQuery = null;
    boolean hasOut = false;
    boolean hasParameters = (param != null && param.length > 0);

    List<ProcedureParameter> outs = null;
    List<ProcedureParameter> ins = null;

    if (hasParameters) {

        // split the params into ins and outs
        outs = new ArrayList<ProcedureParameter>();
        ins = new ArrayList<ProcedureParameter>();

        int type = -1;
        for (int i = 0; i < param.length; i++) {
            type = param[i].getType();
            if (type == DatabaseMetaData.procedureColumnIn || type == DatabaseMetaData.procedureColumnInOut) {

                // add to the ins list
                ins.add(param[i]);

            } else if (type == DatabaseMetaData.procedureColumnOut
                    || type == DatabaseMetaData.procedureColumnResult
                    || type == DatabaseMetaData.procedureColumnReturn
                    || type == DatabaseMetaData.procedureColumnUnknown
                    || type == DatabaseMetaData.procedureColumnInOut) {

                // add to the outs list
                outs.add(param[i]);

            }
        }

        char QUESTION_MARK = '?';
        String COMMA = ", ";

        // init the string buffer
        StringBuilder sb = new StringBuilder("{ ");
        if (!outs.isEmpty()) {

            // build the out params place holders
            for (int i = 0, n = outs.size(); i < n; i++) {

                sb.append(QUESTION_MARK);

                if (i < n - 1) {

                    sb.append(COMMA);
                }

            }

            sb.append(" = ");
        }

        sb.append(" call ");

        if (databaseExecutable.supportCatalogOrSchemaInFunctionOrProcedureCalls()) {

            String namePrefix = null;
            if (databaseExecutable.supportCatalogInFunctionOrProcedureCalls()) {

                namePrefix = databaseExecutable.getCatalogName();

            }
            if (databaseExecutable.supportSchemaInFunctionOrProcedureCalls()) {

                namePrefix = databaseExecutable.getSchemaName();

            }

            if (namePrefix != null) {

                sb.append(namePrefix).append('.');
            }
        }

        sb.append(databaseExecutable.getName()).append("( ");

        // build the ins params place holders
        for (int i = 0, n = ins.size(); i < n; i++) {
            sb.append(QUESTION_MARK);
            if (i < n - 1) {
                sb.append(COMMA);
            }
        }

        sb.append(" ) }");

        // determine if we have out params
        hasOut = !(outs.isEmpty());
        procQuery = sb.toString();
    } else {
        StringBuilder sb = new StringBuilder();
        sb.append("{ call ");

        if (databaseExecutable.getSchemaName() != null) {
            sb.append(databaseExecutable.getSchemaName()).append('.');
        }

        sb.append(databaseExecutable.getName()).append("( ) }");

        procQuery = sb.toString();
    }

    //Log.debug(procQuery);

    // null value literal
    String NULL = "null";

    // clear any warnings
    conn.clearWarnings();

    Log.info("Executing: " + procQuery);

    CallableStatement cstmnt = null;
    try {
        // prepare the statement
        cstmnt = conn.prepareCall(procQuery);
        stmnt = cstmnt;
    } catch (SQLException e) {
        handleException(e);
        statementResult.setSqlException(e);
        return statementResult;
    }

    // check if we are passing parameters
    if (hasParameters) {
        // the parameter index counter
        int index = 1;

        // the java.sql.Type value
        int dataType = -1;

        // the parameter input value
        String value = null;

        // register the out params
        for (int i = 0, n = outs.size(); i < n; i++) {
            //Log.debug("setting out at index: " + index);
            cstmnt.registerOutParameter(index, outs.get(i).getDataType());
            index++;
        }

        try {

            // register the in params
            for (int i = 0, n = ins.size(); i < n; i++) {

                ProcedureParameter procedureParameter = ins.get(i);
                value = procedureParameter.getValue();
                dataType = procedureParameter.getDataType();

                // try infer a type if OTHER
                if (dataType == Types.OTHER) {

                    // checking only for bit/bool for now

                    if (isTrueFalse(value)) {

                        dataType = Types.BOOLEAN;

                    } else if (isBit(value)) {

                        dataType = Types.BIT;
                        value = value.substring(2, value.length() - 1);
                    }

                }

                if (MiscUtils.isNull(value) || value.equalsIgnoreCase(NULL)) {

                    cstmnt.setNull(index, dataType);

                } else {

                    switch (dataType) {

                    case Types.TINYINT:
                        byte _byte = Byte.valueOf(value).byteValue();
                        cstmnt.setShort(index, _byte);
                        break;

                    case Types.SMALLINT:
                        short _short = Short.valueOf(value).shortValue();
                        cstmnt.setShort(index, _short);
                        break;

                    case Types.LONGVARCHAR:
                    case Types.CHAR:
                    case Types.VARCHAR:
                        cstmnt.setString(index, value);
                        break;

                    case Types.BIT:
                    case Types.BOOLEAN:

                        boolean _boolean = false;
                        if (NumberUtils.isNumber(value)) {

                            int number = Integer.valueOf(value);
                            if (number > 0) {

                                _boolean = true;
                            }

                        } else {

                            _boolean = Boolean.valueOf(value).booleanValue();
                        }

                        cstmnt.setBoolean(index, _boolean);
                        break;

                    case Types.BIGINT:
                        long _long = Long.valueOf(value).longValue();
                        cstmnt.setLong(index, _long);
                        break;

                    case Types.INTEGER:
                        int _int = Integer.valueOf(value).intValue();
                        cstmnt.setInt(index, _int);
                        break;

                    case Types.REAL:
                        float _float = Float.valueOf(value).floatValue();
                        cstmnt.setFloat(index, _float);
                        break;

                    case Types.NUMERIC:
                    case Types.DECIMAL:
                        cstmnt.setBigDecimal(index, new BigDecimal(value));
                        break;
                    /*
                                      case Types.DATE:
                                      case Types.TIMESTAMP:
                                      case Types.TIME:
                                        cstmnt.setTimestamp(index, new Timestamp( BigDecimal(value));
                    */
                    case Types.FLOAT:
                    case Types.DOUBLE:
                        double _double = Double.valueOf(value).doubleValue();
                        cstmnt.setDouble(index, _double);
                        break;

                    default:
                        cstmnt.setObject(index, value);

                    }

                }

                // increment the index
                index++;
            }

        } catch (Exception e) {

            statementResult.setOtherErrorMessage(e.getClass().getName() + ": " + e.getMessage());
            return statementResult;
        }

    }

    /*
    test creating function for postgres:
            
    CREATE FUNCTION concat_lower_or_upper(a text, b text, uppercase boolean DEFAULT false)
    RETURNS text
    AS
    $$
     SELECT CASE
        WHEN $3 THEN UPPER($1 || ' ' || $2)
        ELSE LOWER($1 || ' ' || $2)
        END;
    $$
    LANGUAGE SQL IMMUTABLE STRICT;
    */

    try {
        cstmnt.clearWarnings();
        boolean hasResultSet = cstmnt.execute();
        Map<String, Object> results = new HashMap<String, Object>();

        if (hasOut) {
            // incrementing index
            int index = 1;

            // return value from each registered out
            String returnValue = null;

            for (int i = 0; i < param.length; i++) {

                int type = param[i].getType();
                int dataType = param[i].getDataType();

                if (type == DatabaseMetaData.procedureColumnOut
                        || type == DatabaseMetaData.procedureColumnResult
                        || type == DatabaseMetaData.procedureColumnReturn
                        || type == DatabaseMetaData.procedureColumnUnknown
                        || type == DatabaseMetaData.procedureColumnInOut) {

                    switch (dataType) {

                    case Types.TINYINT:
                        returnValue = Byte.toString(cstmnt.getByte(index));
                        break;

                    case Types.SMALLINT:
                        returnValue = Short.toString(cstmnt.getShort(index));
                        break;

                    case Types.LONGVARCHAR:
                    case Types.CHAR:
                    case Types.VARCHAR:
                        returnValue = cstmnt.getString(index);
                        break;

                    case Types.BIT:
                    case Types.BOOLEAN:
                        returnValue = Boolean.toString(cstmnt.getBoolean(index));
                        break;

                    case Types.INTEGER:
                        returnValue = Integer.toString(cstmnt.getInt(index));
                        break;

                    case Types.BIGINT:
                        returnValue = Long.toString(cstmnt.getLong(index));
                        break;

                    case Types.REAL:
                        returnValue = Float.toString(cstmnt.getFloat(index));
                        break;

                    case Types.NUMERIC:
                    case Types.DECIMAL:
                        returnValue = cstmnt.getBigDecimal(index).toString();
                        break;

                    case Types.DATE:
                    case Types.TIME:
                    case Types.TIMESTAMP:
                        returnValue = cstmnt.getDate(index).toString();
                        break;

                    case Types.FLOAT:
                    case Types.DOUBLE:
                        returnValue = Double.toString(cstmnt.getDouble(index));
                        break;

                    }

                    if (returnValue == null) {
                        returnValue = "NULL";
                    }

                    results.put(param[i].getName(), returnValue);
                    index++;
                }

            }

        }

        if (!hasResultSet) {

            statementResult.setUpdateCount(cstmnt.getUpdateCount());

        } else {

            statementResult.setResultSet(cstmnt.getResultSet());
        }

        useCount++;
        statementResult.setOtherResult(results);

    } catch (SQLException e) {

        statementResult.setSqlException(e);

    } catch (Exception e) {

        statementResult.setMessage(e.getMessage());
    }

    return statementResult;
}

From source file:CSVWriter.java

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

    String value = "";

    switch (colType) {
    case Types.BIT:
    case Types.JAVA_OBJECT:
        value = handleObject(rs.getObject(colIndex));
        break;// ww w .  ja  v a2  s.  c  om
    case Types.BOOLEAN:
        boolean b = rs.getBoolean(colIndex);
        value = Boolean.valueOf(b).toString();
        break;
    case NCLOB: // todo : use rs.getNClob
    case Types.CLOB:
        Clob c = rs.getClob(colIndex);
        if (c != null) {
            value = read(c);
        }
        break;
    case Types.BIGINT:
        value = handleLong(rs, colIndex);
        break;
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.REAL:
    case Types.NUMERIC:
        value = handleBigDecimal(rs.getBigDecimal(colIndex));
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        value = handleInteger(rs, colIndex);
        break;
    case Types.DATE:
        value = handleDate(rs, colIndex);
        break;
    case Types.TIME:
        value = handleTime(rs.getTime(colIndex));
        break;
    case Types.TIMESTAMP:
        value = handleTimestamp(rs.getTimestamp(colIndex));
        break;
    case NVARCHAR: // todo : use rs.getNString
    case NCHAR: // todo : use rs.getNString
    case LONGNVARCHAR: // todo : use rs.getNString
    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.batoo.jpa.core.jdbc.adapter.JdbcAdaptor.java

/**
 * Returns the data type of the column./*w ww .j a  va 2s.c  om*/
 * 
 * @param cd
 *            the column definition
 * @param sqlType
 *            the sql type
 * @return the data type
 * 
 * @since $version
 * @author hceylan
 */
protected String getColumnType(AbstractColumn cd, int sqlType) {
    switch (sqlType) {
    case Types.BLOB:
        return "BLOB(" + cd.getLength() + ")";
    case Types.CLOB:
        return "CLOB(" + cd.getLength() + ")";
    case Types.VARCHAR:
        return "VARCHAR(" + cd.getLength() + ")";
    case Types.TIME:
        return "TIME";
    case Types.DATE:
        return "DATE";
    case Types.TIMESTAMP:
        return "TIMESTAMP";
    case Types.CHAR:
        return "CHAR";
    case Types.BOOLEAN:
        return "BOOLEAN";
    case Types.TINYINT:
    case Types.SMALLINT:
        return "SMALLINT";
    case Types.INTEGER:
        return "INTEGER";
    case Types.BIGINT:
        return "BIGINT";
    case Types.FLOAT:
        return "FLOAT" + (cd.getPrecision() > 0 ? "(" + cd.getPrecision() + ")" : "");
    case Types.DOUBLE:
        return "DOUBLE" + (cd.getPrecision() > 0 ? "(" + cd.getPrecision() + ")" : "");
    case Types.DECIMAL:
        return "DECIMAL" + (cd.getPrecision() > 0
                ? "(" + cd.getPrecision() + (cd.getScale() > 0 ? "," + cd.getScale() : "") + ")"
                : "");
    }

    throw new IllegalArgumentException("Unhandled sql type: " + sqlType);
}

From source file:org.siphon.jssql.SqlExecutor.java

private String translateTypeName(int columnType, String columnTypeName) {
    switch (columnType) {
    case Types.VARCHAR:
    case Types.CHAR:
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
        return "STRING";

    case Types.INTEGER:
    case Types.SMALLINT:
        return "INT";
    case Types.BIGINT:
        return "LONG";
    case Types.FLOAT:
        return "FLOAT";
    case Types.REAL:
    case Types.DOUBLE:
        return "DOUBLE";
    case Types.NUMERIC:
    case Types.DECIMAL:
        return "DECIMAL";

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
    case Types.TIME_WITH_TIMEZONE:
        return "DATE";

    case Types.ROWID:
        return "ROWID";

    case Types.BLOB:
        return "BINARY"; // return "BLOB";

    case Types.CLOB:
        return "STRING"; // return "CLOB";

    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return "BINARY";

    case Types.BOOLEAN:
        return "BOOLEAN";

    case Types.ARRAY:
        return "ARRAY";

    case Types.OTHER:
        return columnTypeName.toUpperCase();

    default:// w  w  w .j a  v  a 2 s  .  c  om
        return "UNKNOWN";
    }
}

From source file:org.pentaho.di.jdbc.Support.java

/**
 * Get a String describing the supplied JDBC type constant.
 *
 * @param jdbcType The constant to be decoded.
 * @return The text decode of the type constant as a <code>String</code>.
 *//*from w  w w  .ja v a 2s.  c  om*/
static String getJdbcTypeName(int jdbcType) {
    switch (jdbcType) {
    case java.sql.Types.ARRAY:
        return "ARRAY";
    case java.sql.Types.BIGINT:
        return "BIGINT";
    case java.sql.Types.BINARY:
        return "BINARY";
    case java.sql.Types.BIT:
        return "BIT";
    case java.sql.Types.BLOB:
        return "BLOB";
    case java.sql.Types.BOOLEAN:
        return "BOOLEAN";
    case java.sql.Types.CHAR:
        return "CHAR";
    case java.sql.Types.CLOB:
        return "CLOB";
    //            case JtdsStatement.DATALINK:       return "DATALINK";
    case java.sql.Types.DATE:
        return "DATE";
    case java.sql.Types.DECIMAL:
        return "DECIMAL";
    case java.sql.Types.DISTINCT:
        return "DISTINCT";
    case java.sql.Types.DOUBLE:
        return "DOUBLE";
    case java.sql.Types.FLOAT:
        return "FLOAT";
    case java.sql.Types.INTEGER:
        return "INTEGER";
    case java.sql.Types.JAVA_OBJECT:
        return "JAVA_OBJECT";
    case java.sql.Types.LONGVARBINARY:
        return "LONGVARBINARY";
    case java.sql.Types.LONGVARCHAR:
        return "LONGVARCHAR";
    case java.sql.Types.NULL:
        return "NULL";
    case java.sql.Types.NUMERIC:
        return "NUMERIC";
    case java.sql.Types.OTHER:
        return "OTHER";
    case java.sql.Types.REAL:
        return "REAL";
    case java.sql.Types.REF:
        return "REF";
    case java.sql.Types.SMALLINT:
        return "SMALLINT";
    case java.sql.Types.STRUCT:
        return "STRUCT";
    case java.sql.Types.TIME:
        return "TIME";
    case java.sql.Types.TIMESTAMP:
        return "TIMESTAMP";
    case java.sql.Types.TINYINT:
        return "TINYINT";
    case java.sql.Types.VARBINARY:
        return "VARBINARY";
    case java.sql.Types.VARCHAR:
        return "VARCHAR";
    default:
        return "ERROR";
    }
}

From source file:org.siphon.jssql.SqlExecutor.java

private Object fieldValueToNativeObject(int columnType, ResultSet rs, String columnName)
        throws SQLException, SqlExecutorException, ScriptException {

    // System.out.println("get column " + columnName + " type " +
    // columnType);
    // longraw ? getObject() ??? byte[], 
    // ojdbc6 ? longraw? BLOB 
    // LONGRAW getObject ? LongRaw??
    // BLOB ??? LONGRAWBinary?
    //  LongRaw  BLOB ? t.longraw, t.blob ,  t.blob,
    // t.longraw 

    // if (columnName.equals("datefld")) {
    // System.out.println();
    // }/* w ww.  jav  a2  s . com*/

    Object obj = rs.getObject(columnName);
    if (obj == null) {
        return null;
    } else {
        switch (columnType) {
        case Types.DATE:
            obj = rs.getDate(columnName);
            break;
        case Types.TIME:
            obj = rs.getTime(columnName);
            break;
        case Types.TIMESTAMP:
            obj = rs.getTimestamp(columnName);
            break;
        case Types.TIMESTAMP_WITH_TIMEZONE:
            obj = rs.getTimestamp(columnName);
            break;
        // PG  TIMESTAMP WITH TIMEZONE ??
        // ? JDBC ?????
        // ? joda ?? jdbc ??
        }

    }

    return jdbcReturnTypeToJsObject(obj);
}

From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java

public static String getJavaDatatype(int colType) {

    switch (colType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return "java.lang.String";

    case Types.NUMERIC:
    case Types.DECIMAL:
        return "java.math.BigDecimal";

    case Types.BIT:
        return "boolean";

    case Types.TINYINT:
        return "byte";

    case Types.SMALLINT:
        return "short";

    case Types.INTEGER:
        return "int";

    case Types.BIGINT:
        return "long";

    case Types.REAL:
        return "float";

    case Types.FLOAT:
    case Types.DOUBLE:
        return "double";

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return "byte[]";

    case Types.DATE:
        return "java.sql.Date";

    case Types.TIME:
        return "java.sql.Time";

    case Types.TIMESTAMP:
        return "java.sql.Timestamp";

    case Types.OTHER:
        return "java.lang.Object";
    default:/* w w w.j a v  a 2  s . c om*/
        return null;
    }
}

From source file:net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.java

protected void setTime(int parameterIndex, Object parameterValue, JRPropertiesHolder properties)
        throws SQLException {
    if (parameterValue == null) {
        statement.setNull(parameterIndex, Types.TIME);
    } else {/*ww  w  .j  a v  a  2s .co m*/
        Calendar cal = getParameterCalendar(properties);
        if (log.isDebugEnabled()) {
            log.debug("setting time parameter " + parameterIndex + " as " + parameterValue + " ("
                    + ((java.sql.Time) parameterValue).getTime() + ")" + " with calendar " + cal);
        }
        if (cal == null) {
            statement.setTime(parameterIndex, (java.sql.Time) parameterValue);
        } else {
            statement.setTime(parameterIndex, (java.sql.Time) parameterValue, cal);
        }
    }
}