/** * Convert a SQL type to a value type using SQL type name, in order to * manage SQL type extension mechanism. * * @param sqlType the SQL type * @param sqlTypeName the SQL type name * @return the value type */ private static int convertSQLTypeToValueType(int sqlType, String sqlTypeName) { return convertSQLTypeToValueType(sqlType); }
/** * Get the SQL type from the result set meta data for the given column. This * method uses the SQL type and type name. * * @param meta the meta data * @param columnIndex the column index (1, 2,...) * @return the value type */ public static int getValueTypeFromResultSet(ResultSetMetaData meta, int columnIndex) throws SQLException { return convertSQLTypeToValueType( meta.getColumnType(columnIndex), meta.getColumnTypeName(columnIndex)); }
/** * Adds a column to the result set. * All columns must be added before adding rows. * This method uses the default SQL type names. * * @param name null is replaced with C1, C2,... * @param sqlType the value returned in getColumnType(..) * @param precision the precision * @param scale the scale */ public void addColumn(String name, int sqlType, int precision, int scale) { int valueType = DataType.convertSQLTypeToValueType(sqlType); addColumn(name, sqlType, DataType.getDataType(valueType).name, precision, scale); }
scale = convertScale(sqlType, scale); int displaySize = MathUtils.convertLongToInt(precision); int type = DataType.convertSQLTypeToValueType(sqlType); Column col = new Column(n, type, precision, scale, displaySize); col.setTable(this, i++);
/** * Sets the value of a parameter. The object is converted, if required, to * the specified data type before sending to the database. * Objects of unknown classes are serialized (on the client side). * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value, null is allowed * @param targetSqlType the type as defined in java.sql.Types * @throws SQLException if this object is closed */ @Override public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { try { if (isDebugEnabled()) { debugCode("setObject(" + parameterIndex + ", x, " + targetSqlType + ");"); } int type = DataType.convertSQLTypeToValueType(targetSqlType); if (x == null) { setParameter(parameterIndex, ValueNull.INSTANCE); } else { Value v = DataType.convertToValue(x, type); setParameter(parameterIndex, v.convertTo(type)); } } catch (Exception e) { throw logAndConvert(e); } }