Ejemplo n.º 1
0
 @Override
 public void setToPreparedStatement(
     PreparedStatement ps, int index, Serializable value, Column column) throws SQLException {
   switch (column.getJdbcType()) {
     case Types.VARCHAR:
     case Types.CLOB:
       setToPreparedStatementString(ps, index, value, column);
       return;
     case Types.BIT:
       ps.setBoolean(index, ((Boolean) value).booleanValue());
       return;
     case Types.SMALLINT:
       ps.setInt(index, ((Long) value).intValue());
       return;
     case Types.INTEGER:
     case Types.BIGINT:
       ps.setLong(index, ((Long) value).longValue());
       return;
     case Types.DOUBLE:
       ps.setDouble(index, ((Double) value).doubleValue());
       return;
     case Types.TIMESTAMP:
       setToPreparedStatementTimestamp(ps, index, value, column);
       return;
     case Types.ARRAY:
       Array array = createArrayOf(Types.VARCHAR, (Object[]) value, ps.getConnection());
       ps.setArray(index, array);
       return;
     case Types.OTHER:
       if (column.getType() == ColumnType.FTSTORED) {
         ps.setString(index, (String) value);
         return;
       }
       throw new SQLException("Unhandled type: " + column.getType());
     default:
       throw new SQLException("Unhandled JDBC type: " + column.getJdbcType());
   }
 }
Ejemplo n.º 2
0
 @Override
 @SuppressWarnings("boxing")
 public Serializable getFromResultSet(ResultSet rs, int index, Column column) throws SQLException {
   switch (column.getJdbcType()) {
     case Types.VARCHAR:
     case Types.CLOB:
       return getFromResultSetString(rs, index, column);
     case Types.BIT:
       return rs.getBoolean(index);
     case Types.SMALLINT:
     case Types.INTEGER:
     case Types.BIGINT:
       return rs.getLong(index);
     case Types.DOUBLE:
       return rs.getDouble(index);
     case Types.TIMESTAMP:
       return getFromResultSetTimestamp(rs, index, column);
     case Types.ARRAY:
       Array array = rs.getArray(index);
       return array == null ? null : (Serializable) array.getArray();
   }
   throw new SQLException("Unhandled JDBC type: " + column.getJdbcType());
 }