Example usage for java.sql Types BLOB

List of usage examples for java.sql Types BLOB

Introduction

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

Prototype

int BLOB

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

Click Source Link

Document

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

Usage

From source file:axiom.objectmodel.db.NodeManager.java

private void setStatementValues(PreparedStatement stmt, int stmtNumber, Property p, int columnType)
        throws SQLException {
    if (p.getValue() == null) {
        stmt.setNull(stmtNumber, columnType);
    } else {//from   ww w.j  a v  a  2 s  . c  om
        switch (columnType) {
        case Types.BIT:
        case Types.TINYINT:
        case Types.BIGINT:
        case Types.SMALLINT:
        case Types.INTEGER:
            stmt.setLong(stmtNumber, p.getIntegerValue());

            break;

        case Types.REAL:
        case Types.FLOAT:
        case Types.DOUBLE:
        case Types.NUMERIC:
        case Types.DECIMAL:
            stmt.setDouble(stmtNumber, p.getFloatValue());

            break;

        case Types.VARBINARY:
        case Types.BINARY:
        case Types.BLOB:
            stmt.setString(stmtNumber, p.getStringValue());

            break;

        case Types.LONGVARBINARY:
        case Types.LONGVARCHAR:
            try {
                stmt.setString(stmtNumber, p.getStringValue());
            } catch (SQLException x) {
                String str = p.getStringValue();
                Reader r = new StringReader(str);

                stmt.setCharacterStream(stmtNumber, r, str.length());
            }

            break;

        case Types.CLOB:
            String val = p.getStringValue();
            Reader isr = new StringReader(val);
            stmt.setCharacterStream(stmtNumber, isr, val.length());

            break;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.OTHER:
            stmt.setString(stmtNumber, p.getStringValue());

            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            stmt.setTimestamp(stmtNumber, p.getTimestampValue());

            break;

        case Types.NULL:
            stmt.setNull(stmtNumber, 0);

            break;

        default:
            stmt.setString(stmtNumber, p.getStringValue());

            break;
        }
    }
}

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

/**
 * Helper method esp. for the {@link ModelBasedResultSetIterator} class that retrieves
 * the value for a column from the given result set. If a table was specified,
 * and it contains the column, then the jdbc type defined for the column is used for extracting
 * the value, otherwise the object directly retrieved from the result set is returned.<br/>
 * The method is defined here rather than in the {@link ModelBasedResultSetIterator} class
 * so that concrete platforms can modify its behavior.
 * /*from  w w w. j  a  v a2 s .co m*/
 * @param resultSet  The result set
 * @param columnName The name of the column
 * @param table      The table
 * @return The value
 */
protected Object getObjectFromResultSet(ResultSet resultSet, String columnName, Table table)
        throws SQLException {
    Column column = (table == null ? null : table.findColumn(columnName, isDelimitedIdentifierModeOn()));
    Object value = null;

    if (column != null) {
        int originalJdbcType = column.getTypeCode();
        int targetJdbcType = getPlatformInfo().getTargetJdbcType(originalJdbcType);
        int jdbcType = originalJdbcType;

        // in general we're trying to retrieve the value using the original type
        // but sometimes we also need the target type:
        if ((originalJdbcType == Types.BLOB) && (targetJdbcType != Types.BLOB)) {
            // we should not use the Blob interface if the database doesn't map to this type 
            jdbcType = targetJdbcType;
        }
        if ((originalJdbcType == Types.CLOB) && (targetJdbcType != Types.CLOB)) {
            // we should not use the Clob interface if the database doesn't map to this type 
            jdbcType = targetJdbcType;
        }
        value = extractColumnValue(resultSet, columnName, 0, jdbcType);
    } else {
        value = resultSet.getObject(columnName);
    }
    return resultSet.wasNull() ? null : value;
}

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

/**
 * Helper method for retrieving the value for a column from the given result set
 * using the type code of the column./*from w  w  w . j a v  a  2 s .c o m*/
 * 
 * @param resultSet The result set
 * @param column    The column
 * @param idx       The value's index in the result set (starting from 1) 
 * @return The value
 */
protected Object getObjectFromResultSet(ResultSet resultSet, Column column, int idx) throws SQLException {
    int originalJdbcType = column.getTypeCode();
    int targetJdbcType = getPlatformInfo().getTargetJdbcType(originalJdbcType);
    int jdbcType = originalJdbcType;
    Object value = null;

    // in general we're trying to retrieve the value using the original type
    // but sometimes we also need the target type:
    if ((originalJdbcType == Types.BLOB) && (targetJdbcType != Types.BLOB)) {
        // we should not use the Blob interface if the database doesn't map to this type 
        jdbcType = targetJdbcType;
    }
    if ((originalJdbcType == Types.CLOB) && (targetJdbcType != Types.CLOB)) {
        // we should not use the Clob interface if the database doesn't map to this type 
        jdbcType = targetJdbcType;
    }
    value = extractColumnValue(resultSet, null, idx, jdbcType);
    return resultSet.wasNull() ? null : value;
}

From source file:uk.ac.ed.epcc.webapp.model.data.Repository.java

/**
 * populate an object from a ResultSet//w ww .ja  v  a  2s  . c  om
 * 
 * It seems to work if we always qualify the field names but its slower
 * 
 * @param rs
 *            ResultSet
 * @param qualify
 *            boolean qualify the field names with the table name as
 *            ResultSet is from a join
 * @throws DataFault
 * 
 * @throws ConsistencyError
 */
public void setFromResultSet(Record r, ResultSet rs, boolean qualify) throws DataFault, DataNotFoundException {
    int id;
    synchronized (r) {
        r.clear();
        try {
            /*
             * This is more robust though its slightly faster to get fields
             * by col number
             */
            if (use_id) {
                String uniqueIdName = getUniqueIdName(qualify);
                id = rs.getInt(uniqueIdName);
                r.setInitialID(id);

                // for backwards compatibility

                if (id <= 0) {
                    // This can happen with a join used to pre-populate a cached link
                    // when the reference value is invalid
                    throw new DataNotFoundException("No ID value found " + uniqueIdName + ":" + id);
                }
            } else {
                id = 0;
            }

            //         Logger log=null;
            //         if( ctx.isFeatureOn("log_fetch")){
            //            log=ctx.getService(LoggerService.class).getLogger(getClass());
            //         }

            for (Iterator<String> i = getFields().iterator(); i.hasNext();) {
                String field = i.next();
                FieldInfo info = fields.get(field);
                Object value = rs.getObject(info.getName(qualify));

                if (value != null) {
                    if (info.getType() == Types.BLOB) {
                        if (value instanceof Blob) {
                            value = new BlobStreamData(ctx, (Blob) value);
                        } else {
                            throw new DataFault("Unexpected Blob type " + value.getClass().getName());
                        }
                    }
                    //               if( log != null ){
                    //                  log.debug(info.getName(true)+" is "+value.toString()+" "+value.getClass().getCanonicalName());
                    //               }
                    // want these to be clean by default
                    r.rawPut(field, value);
                }
            }

        } catch (SQLException e) {
            r.clear();
            throw new DataFault("Exception in setContents", e);
        }
        // store this object in the cache if appropriate
        if (use_cache && use_id) {
            synchronized (this) {
                Map<Integer, Record> cache;
                Integer key = id;
                if ((cache = getCache()) != null && !cache.containsKey(key)) {
                    // Store copy so cached copy not changed
                    cache.put(key, (Record) r.clone());
                    cache = null;
                }
            }
        }
    }
}

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.
 * //from w w  w . ja va  2  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:org.apache.openjpa.jdbc.sql.DBDictionary.java

/**
 * Append the numeric parts of a mathematical function.
 *
 * @param buf the SQL buffer to write the math function
 * @param op the mathematical operation to perform
 * @param lhs the left hand side of the math function
 * @param rhs the right hand side of the math function
 *///from w  w  w.  j  a v a2s. c o  m
public void mathFunction(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs) {
    boolean castlhs = false;
    boolean castrhs = false;
    Class lc = Filters.wrap(lhs.getType());
    Class rc = Filters.wrap(rhs.getType());
    int type = 0;
    if (requiresCastForMathFunctions && (lc != rc || (lhs.isConstant() || rhs.isConstant()))) {
        Class c = Filters.promote(lc, rc);
        type = getJDBCType(JavaTypes.getTypeCode(c), false);
        if (type != Types.VARBINARY && type != Types.BLOB) {
            castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c;
            castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c;
        }
    }

    boolean mod = "MOD".equals(op);
    if (mod) {
        if (supportsModOperator)
            op = "%";
        else
            buf.append(op);
    }
    buf.append("(");

    if (castlhs)
        appendCast(buf, lhs, type);
    else
        lhs.appendTo(buf);

    if (mod && !supportsModOperator)
        buf.append(", ");
    else
        buf.append(" ").append(op).append(" ");

    if (castrhs)
        appendCast(buf, rhs, type);
    else
        rhs.appendTo(buf);

    buf.append(")");
}

From source file:org.apache.openjpa.jdbc.sql.DBDictionary.java

/**
 * Append a comparison.//from  www.  j  a va  2  s .  c o  m
 *
 * @param buf the SQL buffer to write the comparison
 * @param op the comparison operation to perform
 * @param lhs the left hand side of the comparison
 * @param rhs the right hand side of the comparison
 */
public void comparison(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs) {
    boolean lhsxml = lhs.getXPath() != null;
    boolean rhsxml = rhs.getXPath() != null;
    if (lhsxml || rhsxml) {
        appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml);
        return;
    }
    boolean castlhs = false;
    boolean castrhs = false;
    Class lc = Filters.wrap(lhs.getType());
    Class rc = Filters.wrap(rhs.getType());

    // special case of comparison of two boolean constants
    // because some databases do not like false = false or false = true
    // but all databases understand 1 = 0 or 0 <> 1 etc.
    if (lc == rc && lc == Boolean.class && lhs.isConstant() && rhs.isConstant()) {
        String lvalue = Boolean.TRUE.equals(lhs.getValue()) ? "1" : "0";
        String rvalue = Boolean.TRUE.equals(rhs.getValue()) ? "1" : "0";
        buf.append(lvalue).append(op).append(rvalue);
        return;
    }
    int type = 0;
    if (requiresCastForComparisons && (lc != rc || (lhs.isConstant() && rhs.isConstant()))) {
        Class c = Filters.promote(lc, rc);
        type = getJDBCType(JavaTypes.getTypeCode(c), false);
        if (type != Types.VARBINARY && type != Types.BLOB) {
            castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c;
            castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c;
            castlhs = castlhs && lhs.requiresCast();
            castrhs = castrhs && rhs.requiresCast();
        }
    }

    if (castlhs)
        appendCast(buf, lhs, type);
    else
        lhs.appendTo(buf);

    buf.append(" ").append(op).append(" ");

    if (castrhs)
        appendCast(buf, rhs, type);
    else
        rhs.appendTo(buf);
}

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:/*from w w w.j a v a  2 s .  c o m*/
        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  . j  av a2  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();/*from  w w w .  j  a v 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;
}