Example usage for java.sql Types LONGVARCHAR

List of usage examples for java.sql Types LONGVARCHAR

Introduction

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

Prototype

int LONGVARCHAR

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

Click Source Link

Document

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

Usage

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>CachedRowSetImpl</code> object as a
 * <code>java.sql.Time</code> object.
 *
 * @param columnIndex the first column is <code>1</code>, the second
 *        is <code>2</code>, and so on; must be <code>1</code> or larger
 *        and equal to or less than the number of columns in the rowset
 * @return the column value; if the value is SQL <code>NULL</code>, the
 *         result is <code>null</code>
 * @throws SQLException if the given column index is out of bounds,
 *         the cursor is not on a valid row, or this method fails
 *//*from  w w  w .  j  a v  a  2 s .c om*/
public java.sql.Time getTime(int columnIndex) throws SQLException {
    Object value;

    // sanity check.
    checkIndex(columnIndex);
    // make sure the cursor is on a valid row
    checkCursor();

    setLastValueNull(false);
    value = getCurrentRow().getColumnObject(columnIndex);

    // check for SQL NULL
    if (value == null) {
        setLastValueNull(true);
        return null;
    }

    /*
     * The object coming back from the db could be
     * a date, a timestamp, or a char field variety.
     * If it's a date type return it, a timestamp
     * we turn into a long and then into a date,
     * char strings we try to parse. Yuck.
     */
    switch (RowSetMD.getColumnType(columnIndex)) {
    case java.sql.Types.TIME: {
        return (java.sql.Time) value;
    }
    case java.sql.Types.TIMESTAMP: {
        long sec = ((java.sql.Timestamp) value).getTime();
        return new java.sql.Time(sec);
    }
    case java.sql.Types.CHAR:
    case java.sql.Types.VARCHAR:
    case java.sql.Types.LONGVARCHAR: {
        java.util.Date parsedDate = parseDate(columnIndex, value);
        return new java.sql.Time(parsedDate.getTime());
    }
    default: {
        throw new SQLException(
                MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(),
                        new Object[] { value.toString().trim(), columnIndex }));
    }
    }
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>CachedRowSetImpl</code> object as a
 * <code>java.sql.Timestamp</code> object.
 *
 * @param columnIndex the first column is <code>1</code>, the second
 *        is <code>2</code>, and so on; must be <code>1</code> or larger
 *        and equal to or less than the number of columns in the rowset
 * @return the column value; if the value is SQL <code>NULL</code>, the
 *         result is <code>null</code>
 * @throws SQLException if the given column index is out of bounds,
 *            the cursor is not on a valid row, or this method fails
 */// w  w w . j a v  a2s. c o  m
public java.sql.Timestamp getTimestamp(int columnIndex) throws SQLException {
    Object value;

    // sanity check.
    checkIndex(columnIndex);
    // make sure the cursor is on a valid row
    checkCursor();

    setLastValueNull(false);
    value = getCurrentRow().getColumnObject(columnIndex);

    // check for SQL NULL
    if (value == null) {
        setLastValueNull(true);
        return null;
    }

    /*
     * The object coming back from the db could be
     * a date, a timestamp, or a char field variety.
     * If it's a date type return it; a timestamp
     * we turn into a long and then into a date;
     * char strings we try to parse. Yuck.
     */
    switch (RowSetMD.getColumnType(columnIndex)) {
    case java.sql.Types.TIMESTAMP: {
        return (java.sql.Timestamp) value;
    }
    case java.sql.Types.TIME: {
        long sec = ((java.sql.Time) value).getTime();
        return new java.sql.Timestamp(sec);
    }
    case java.sql.Types.DATE: {
        long sec = ((java.sql.Date) value).getTime();
        return new java.sql.Timestamp(sec);
    }
    case java.sql.Types.CHAR:
    case java.sql.Types.VARCHAR:
    case java.sql.Types.LONGVARCHAR: {
        java.util.Date parsedDate = parseDate(columnIndex, value);
        return new Timestamp(parsedDate.getTime());
    }
    default: {
        throw new SQLException(
                MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.timefail").toString(),
                        new Object[] { value.toString().trim(), columnIndex }));
    }
    }
}

From source file:org.apache.ddlutils.platform.PlatformImplBase.java

/**
 * This is the core method to retrieve a value for a column from a result set. Its  primary
 * purpose is to call the appropriate method on the result set, and to provide an extension
 * point where database-specific implementations can change this behavior.
 * //w  w w .  j  a  v  a2  s .c o m
 * @param resultSet  The result set to extract the value from
 * @param columnName The name of the column; can be <code>null</code> in which case the
  *                   <code>columnIdx</code> will be used instead
  * @param columnIdx  The index of the column's value in the result set; is only used if
  *                   <code>columnName</code> is <code>null</code>
 * @param jdbcType   The jdbc type to extract
 * @return The value
 * @throws SQLException If an error occurred while accessing the result set
 */
protected Object extractColumnValue(ResultSet resultSet, String columnName, int columnIdx, int jdbcType)
        throws SQLException {
    boolean useIdx = (columnName == null);
    Object value;

    switch (jdbcType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        value = useIdx ? resultSet.getString(columnIdx) : resultSet.getString(columnName);
        break;
    case Types.NUMERIC:
    case Types.DECIMAL:
        value = useIdx ? resultSet.getBigDecimal(columnIdx) : resultSet.getBigDecimal(columnName);
        break;
    case Types.BIT:
    case Types.BOOLEAN:
        value = new Boolean(useIdx ? resultSet.getBoolean(columnIdx) : resultSet.getBoolean(columnName));
        break;
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
        value = new Integer(useIdx ? resultSet.getInt(columnIdx) : resultSet.getInt(columnName));
        break;
    case Types.BIGINT:
        value = new Long(useIdx ? resultSet.getLong(columnIdx) : resultSet.getLong(columnName));
        break;
    case Types.REAL:
        value = new Float(useIdx ? resultSet.getFloat(columnIdx) : resultSet.getFloat(columnName));
        break;
    case Types.FLOAT:
    case Types.DOUBLE:
        value = new Double(useIdx ? resultSet.getDouble(columnIdx) : resultSet.getDouble(columnName));
        break;
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        value = useIdx ? resultSet.getBytes(columnIdx) : resultSet.getBytes(columnName);
        break;
    case Types.DATE:
        value = useIdx ? resultSet.getDate(columnIdx) : resultSet.getDate(columnName);
        break;
    case Types.TIME:
        value = useIdx ? resultSet.getTime(columnIdx) : resultSet.getTime(columnName);
        break;
    case Types.TIMESTAMP:
        value = useIdx ? resultSet.getTimestamp(columnIdx) : resultSet.getTimestamp(columnName);
        break;
    case Types.CLOB:
        Clob clob = useIdx ? resultSet.getClob(columnIdx) : resultSet.getClob(columnName);

        if (clob == null) {
            value = null;
        } else {
            long length = clob.length();

            if (length > Integer.MAX_VALUE) {
                value = clob;
            } else if (length == 0) {
                // the javadoc is not clear about whether Clob.getSubString
                // can be used with a substring length of 0
                // thus we do the safe thing and handle it ourselves
                value = "";
            } else {
                value = clob.getSubString(1l, (int) length);
            }
        }
        break;
    case Types.BLOB:
        Blob blob = useIdx ? resultSet.getBlob(columnIdx) : resultSet.getBlob(columnName);

        if (blob == null) {
            value = null;
        } else {
            long length = blob.length();

            if (length > Integer.MAX_VALUE) {
                value = blob;
            } else if (length == 0) {
                // the javadoc is not clear about whether Blob.getBytes
                // can be used with for 0 bytes to be copied
                // thus we do the safe thing and handle it ourselves
                value = new byte[0];
            } else {
                value = blob.getBytes(1l, (int) length);
            }
        }
        break;
    case Types.ARRAY:
        value = useIdx ? resultSet.getArray(columnIdx) : resultSet.getArray(columnName);
        break;
    case Types.REF:
        value = useIdx ? resultSet.getRef(columnIdx) : resultSet.getRef(columnName);
        break;
    default:
        value = useIdx ? resultSet.getObject(columnIdx) : resultSet.getObject(columnName);
        break;
    }
    return resultSet.wasNull() ? null : value;
}

From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java

private static String sqlTypeToString(int sqlType) {
    switch (sqlType) {
    case Types.ARRAY:
        return "ARRAY";
    case Types.BIGINT:
        return "BIGINT";
    case Types.BINARY:
        return "BINARY";
    case Types.BIT:
        return "BIT";
    case Types.BLOB:
        return "BLOB";
    case Types.BOOLEAN:
        return "BOOLEAN";
    case Types.CHAR:
        return "CHAR";
    case Types.CLOB:
        return "CLOB";
    case Types.DATALINK:
        return "DATALINK";
    case Types.DATE:
        return "DATE";
    case Types.DECIMAL:
        return "DECIMAL";
    case Types.DISTINCT:
        return "DISTINCT";
    case Types.DOUBLE:
        return "DOUBLE";
    case Types.FLOAT:
        return "FLOAT";
    case Types.INTEGER:
        return "INTEGER";
    case Types.JAVA_OBJECT:
        return "JAVA_OBJECT";
    case Types.LONGNVARCHAR:
        return "LONGNVARCHAR";
    case Types.LONGVARBINARY:
        return "LONGVARBINARY";
    case Types.LONGVARCHAR:
        return "LONGVARCHAR";
    case Types.NCHAR:
        return "NCHAR";
    case Types.NCLOB:
        return "NCLOB";
    case Types.NULL:
        return "NULL";
    case Types.NUMERIC:
        return "NUMERIC";
    case Types.NVARCHAR:
        return "NVARCHAR";
    case Types.OTHER:
        return "OTHER";
    case Types.REAL:
        return "REAL";
    case Types.REF:
        return "REF";
    case Types.ROWID:
        return "ROWID";
    case Types.SMALLINT:
        return "SMALLINT";
    case Types.SQLXML:
        return "SQLXML";
    case Types.STRUCT:
        return "STRUCT";
    case Types.TIME:
        return "TIME";
    case Types.TIMESTAMP:
        return "TIMESTAMP";
    case Types.TINYINT:
        return "TINYINT";
    case Types.VARBINARY:
        return "VARBINARY";
    case Types.VARCHAR:
        return "VARCHAR";
    default:// w  w  w. j  a  v  a  2s .com
        return "UNKNOWN";
    }
}

From source file:ProcessRequest.java

public JSONArray parseQueryResults(ResultSet rs, String table) throws SQLException, JSONException {
    JSONArray resultJSONArray = new JSONArray();
    ResultSetMetaData rsmd = rs.getMetaData();
    int columns = rsmd.getColumnCount();
    while (rs.next()) {
        JSONObject result = new JSONObject();
        JSONObject resultMeta = new JSONObject();
        resultMeta.put("table", table);
        result.put("metadata", resultMeta);
        for (int i = 1; i <= columns; i++) {
            //out.println("<td>"+rs.getString(i)+"</td>");
            int type = rsmd.getColumnType(i);
            //result.put(rsmd.getColumnName(i), rs.get)
            switch (type) {
            case Types.BIT:
                result.put(rsmd.getColumnName(i), rs.getBoolean(i));
                break;
            case Types.TINYINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.SMALLINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.INTEGER:
                //System.out.println(rsmd.getColumnName(i) + "  type: "+type);
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.BIGINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.FLOAT:
                result.put(rsmd.getColumnName(i), rs.getFloat(i));
                break;
            case Types.REAL:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.DOUBLE:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.NUMERIC:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.DECIMAL:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.CHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.VARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.LONGVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.DATE: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }/*w  w w .  ja va 2 s. c  o m*/
            case Types.TIME: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.TIMESTAMP: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.BINARY:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.VARBINARY:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.LONGVARBINARY:
                result.put(rsmd.getColumnName(i), rs.getLong(i));
                break;
            case Types.NULL:
                result.put(rsmd.getColumnName(i), "");
                break;
            case Types.BOOLEAN:
                result.put(rsmd.getColumnName(i), rs.getBoolean(i));
                break;
            case Types.ROWID:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.NCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.NVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.LONGNVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.SQLXML:
            case Types.NCLOB:
            case Types.DATALINK:
            case Types.REF:
            case Types.OTHER:
            case Types.JAVA_OBJECT:
            case Types.DISTINCT:
            case Types.STRUCT:
            case Types.ARRAY:
            case Types.BLOB:
            case Types.CLOB:
            default:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            }
        }
        //if(table.equals("Ticket"))
        //System.out.println(result.toString(5));
        resultJSONArray.put(result);
    }
    return resultJSONArray;
}

From source file:ProcessRequest.java

public void parseQueryResults(ResultSet rs, String table, OutputStream os, boolean append)
        throws SQLException, JSONException, IOException {
    //JSONArray resultJSONArray = new JSONArray();
    ResultSetMetaData rsmd = rs.getMetaData();
    int columns = rsmd.getColumnCount();
    rs.last();/* w  w  w .j av  a  2 s. c  o m*/
    int rows = rs.getRow();
    os.write(new String("total rows: " + rows).getBytes());
    rs.first();
    int rowCount = 0;
    while (rs.next()) {
        if (!rs.isFirst() || append) {
            os.write(new String(",\n").getBytes());
            os.write(new String("" + rowCount).getBytes());
        }
        if (rowCount >= 69)
            System.out.println("break point");
        rowCount++;
        JSONObject result = new JSONObject();
        JSONObject resultMeta = new JSONObject();
        resultMeta.put("table", table);
        result.put("metadata", resultMeta);
        for (int i = 1; i <= columns; i++) {
            //out.println("<td>"+rs.getString(i)+"</td>");
            int type = rsmd.getColumnType(i);
            //result.put(rsmd.getColumnName(i), rs.get)
            switch (type) {
            case Types.BIT:
                result.put(rsmd.getColumnName(i), rs.getBoolean(i));
                break;
            case Types.TINYINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.SMALLINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.INTEGER:
                //System.out.println(rsmd.getColumnName(i) + "  type: "+type);
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.BIGINT:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.FLOAT:
                result.put(rsmd.getColumnName(i), rs.getFloat(i));
                break;
            case Types.REAL:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.DOUBLE:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.NUMERIC:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.DECIMAL:
                result.put(rsmd.getColumnName(i), rs.getDouble(i));
                break;
            case Types.CHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.VARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.LONGVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.DATE: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.TIME: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.TIMESTAMP: {
                java.util.Date date = rs.getDate(i);
                result.put(rsmd.getColumnName(i), date.getTime());
                break;
            }
            case Types.BINARY:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.VARBINARY:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.LONGVARBINARY:
                result.put(rsmd.getColumnName(i), rs.getLong(i));
                break;
            case Types.NULL:
                result.put(rsmd.getColumnName(i), "");
                break;
            case Types.BOOLEAN:
                result.put(rsmd.getColumnName(i), rs.getBoolean(i));
                break;
            case Types.ROWID:
                result.put(rsmd.getColumnName(i), rs.getInt(i));
                break;
            case Types.NCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.NVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.LONGNVARCHAR:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            case Types.SQLXML:
            case Types.NCLOB:
            case Types.DATALINK:
            case Types.REF:
            case Types.OTHER:
            case Types.JAVA_OBJECT:
            case Types.DISTINCT:
            case Types.STRUCT:
            case Types.ARRAY:
            case Types.BLOB:
            case Types.CLOB:
            default:
                result.put(rsmd.getColumnName(i), rs.getString(i));
                break;
            }
        }
        //if(table.equals("Ticket"))
        //System.out.println(result.toString(5));
        //if(result.getInt("TicketNumber")==126868)
        //   System.out.println("break point");
        //resultJSONArray.put(result);
        os.write(result.toString(5).getBytes());
    }
    //return resultJSONArray;
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Indicates whether the given SQL data type is a string type.
 *
 * @param type one of the constants from <code>java.sql.Types</code>
 * @return <code>true</code> if the given type is <code>CHAR</code>,'
 *         <code>VARCHAR</code>, or <code>LONGVARCHAR</code>;
 *         <code>false</code> otherwise
 *//*  w  w  w.j av a 2s  . co m*/
private boolean isString(int type) {
    switch (type) {
    case java.sql.Types.CHAR:
    case java.sql.Types.VARCHAR:
    case java.sql.Types.LONGVARCHAR:
        return true;
    default:
        return false;
    }
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Converts the given <code>Object</code> in the Java programming language
 * to the standard mapping for the specified SQL target data type.
 * The conversion must be to a string or numeric type, but there are no
 * restrictions on the type to be converted.  If the source type and target
 * type are the same, the given object is simply returned.
 *
 * @param srcObj the <code>Object</code> in the Java programming language
 *               that is to be converted to the target type
 * @param srcType the data type that is the standard mapping in SQL of the
 *                object to be converted; must be one of the constants in
 *                <code>java.sql.Types</code>
 * @param trgType the SQL data type to which to convert the given object;
 *                must be one of the following constants in
 *                <code>java.sql.Types</code>: <code>NUMERIC</code>,
 *         <code>DECIMAL</code>, <code>BIT</code>, <code>TINYINT</code>,
 *         <code>SMALLINT</code>, <code>INTEGER</code>, <code>BIGINT</code>,
 *         <code>REAL</code>, <code>DOUBLE</code>, <code>FLOAT</code>,
 *         <code>VARCHAR</code>, <code>LONGVARCHAR</code>, or <code>CHAR</code>
 * @return an <code>Object</code> value.that is
 *         the standard object mapping for the target SQL type
 * @throws SQLException if the given target type is not one of the string or
 *         numeric types in <code>java.sql.Types</code>
 *//*  ww w  . j av a 2  s .co m*/
private Object convertNumeric(Object srcObj, int srcType, int trgType) throws SQLException {

    if (srcType == trgType) {
        return srcObj;
    }

    if (isNumeric(trgType) == false && isString(trgType) == false) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString() + trgType);
    }

    try {
        switch (trgType) {
        case java.sql.Types.BIT:
            Integer i = new Integer(srcObj.toString().trim());
            return i.equals(new Integer((int) 0)) ? new Boolean(false) : new Boolean(true);
        case java.sql.Types.TINYINT:
            return new Byte(srcObj.toString().trim());
        case java.sql.Types.SMALLINT:
            return new Short(srcObj.toString().trim());
        case java.sql.Types.INTEGER:
            return new Integer(srcObj.toString().trim());
        case java.sql.Types.BIGINT:
            return new Long(srcObj.toString().trim());
        case java.sql.Types.NUMERIC:
        case java.sql.Types.DECIMAL:
            return new BigDecimal(srcObj.toString().trim());
        case java.sql.Types.REAL:
        case java.sql.Types.FLOAT:
            return new Float(srcObj.toString().trim());
        case java.sql.Types.DOUBLE:
            return new Double(srcObj.toString().trim());
        case java.sql.Types.CHAR:
        case java.sql.Types.VARCHAR:
        case java.sql.Types.LONGVARCHAR:
            return new String(srcObj.toString());
        default:
            throw new SQLException(
                    resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString() + trgType);
        }
    } catch (NumberFormatException ex) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString() + trgType);
    }
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Converts the given <code>Object</code> in the Java programming language
 * to the standard object mapping for the specified SQL target data type.
 * The conversion must be to a string or temporal type, and there are also
 * restrictions on the type to be converted.
 * <P>/*from  w w w .  j  a  v a2  s  .  c o  m*/
 * <TABLE ALIGN="CENTER" BORDER CELLPADDING=10 BORDERCOLOR="#0000FF"
 * <CAPTION ALIGN="CENTER"><B>Parameters and Return Values</B></CAPTION>
 * <TR>
 *   <TD><B>Source SQL Type</B>
 *   <TD><B>Target SQL Type</B>
 *   <TD><B>Object Returned</B>
 * </TR>
 * <TR>
 *   <TD><code>TIMESTAMP</code>
 *   <TD><code>DATE</code>
 *   <TD><code>java.sql.Date</code>
 * </TR>
 * <TR>
 *   <TD><code>TIMESTAMP</code>
 *   <TD><code>TIME</code>
 *   <TD><code>java.sql.Time</code>
 * </TR>
 * <TR>
 *   <TD><code>TIME</code>
 *   <TD><code>TIMESTAMP</code>
 *   <TD><code>java.sql.Timestamp</code>
 * </TR>
 * <TR>
 *   <TD><code>DATE</code>, <code>TIME</code>, or <code>TIMESTAMP</code>
 *   <TD><code>CHAR</code>, <code>VARCHAR</code>, or <code>LONGVARCHAR</code>
 *   <TD><code>java.lang.String</code>
 * </TR>
 * </TABLE>
 * <P>
 * If the source type and target type are the same,
 * the given object is simply returned.
 *
 * @param srcObj the <code>Object</code> in the Java programming language
 *               that is to be converted to the target type
 * @param srcType the data type that is the standard mapping in SQL of the
 *                object to be converted; must be one of the constants in
 *                <code>java.sql.Types</code>
 * @param trgType the SQL data type to which to convert the given object;
 *                must be one of the following constants in
 *                <code>java.sql.Types</code>: <code>DATE</code>,
 *         <code>TIME</code>, <code>TIMESTAMP</code>, <code>CHAR</code>,
 *         <code>VARCHAR</code>, or <code>LONGVARCHAR</code>
 * @return an <code>Object</code> value.that is
 *         the standard object mapping for the target SQL type
 * @throws SQLException if the given target type is not one of the string or
 *         temporal types in <code>java.sql.Types</code>
 */
private Object convertTemporal(Object srcObj, int srcType, int trgType) throws SQLException {

    if (srcType == trgType) {
        return srcObj;
    }

    if (isNumeric(trgType) == true || (isString(trgType) == false && isTemporal(trgType) == false)) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
    }

    try {
        switch (trgType) {
        case java.sql.Types.DATE:
            if (srcType == java.sql.Types.TIMESTAMP) {
                return new java.sql.Date(((java.sql.Timestamp) srcObj).getTime());
            } else {
                throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
            }
        case java.sql.Types.TIMESTAMP:
            if (srcType == java.sql.Types.TIME) {
                return new Timestamp(((java.sql.Time) srcObj).getTime());
            } else {
                return new Timestamp(((java.sql.Date) srcObj).getTime());
            }
        case java.sql.Types.TIME:
            if (srcType == java.sql.Types.TIMESTAMP) {
                return new Time(((java.sql.Timestamp) srcObj).getTime());
            } else {
                throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
            }
        case java.sql.Types.CHAR:
        case java.sql.Types.VARCHAR:
        case java.sql.Types.LONGVARCHAR:
            return new String(srcObj.toString());
        default:
            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
        }
    } catch (NumberFormatException ex) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
    }

}