Java Code Examples for java.sql.Types#DATE

The following examples show how to use java.sql.Types#DATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Column.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the type of the given type as simple
 * string representation, either "i" for intergers,
 * "s" for strings and "d" for date types
 *
 * @param cType the column type
 * @return the simple type string represenation
 */
static public int getTypeID (int cType) {
	switch (cType) {
	case Types.DECIMAL:
	case Types.NUMERIC:
	case Types.DOUBLE:
	case Types.FLOAT:
	case Types.REAL:
	case Types.BIGINT:
	case Types.INTEGER:
	case Types.SMALLINT:
	case Types.TINYINT:
		return NUMERIC;
	case Types.CHAR:
	case Types.VARCHAR:
	case Types.BLOB:
	case Types.CLOB:
		return STRING;
	case Types.DATE:
	case Types.TIME:
	case Types.TIMESTAMP:
		return DATE;
	default:
		return UNSET;
	}
}
 
Example 2
Source File: MatchedColumnsHelper.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public List<ColumnInfo> getDateTypeColumns(TableInfo table, int numCols) {
  List<ColumnInfo> columns = table.getColumnList();
  int colCnt = columns.size();
  List<ColumnInfo> partColumns = new ArrayList<ColumnInfo>();
  for (int i = 0; i < numCols; i++) {
    ColumnInfo col = null;
    boolean f = false;
    for (int j = 0; j < 10 && !f; j++) {
      col = columns.get(random.nextInt(colCnt));
      if ((col.getColumnType() == Types.DATE
          || col.getColumnType() == Types.TIME || col.getColumnType() == Types.TIMESTAMP)
          && !partColumns.contains(col)) {
        f = true;
      }
    }
    if (f)
      partColumns.add(col);
  }
  return partColumns;
}
 
Example 3
Source File: UnaryDateTimestampOperatorNode.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param operand    The operand of the function
 * @param targetType The type of the result. Timestamp or Date.
 * @throws StandardException Thrown on error
 */

public void init(Object operand,Object targetType)
        throws StandardException{
    setType((DataTypeDescriptor)targetType);
    switch(getTypeServices().getJDBCTypeId()){
        case Types.DATE:
            super.init(operand,"date",DATE_METHOD_NAME);
            break;

        case Types.TIMESTAMP:
            super.init(operand,"timestamp",TIMESTAMP_METHOD_NAME);
            break;

        default:
            if(SanityManager.DEBUG)
                SanityManager.NOTREACHED();
            super.init(operand);
    }
}
 
Example 4
Source File: FromDatabaseSchemaToSpecification.java    From barleydb with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected JdbcType getNodeJdbcType(Column column) {
    switch(column.getColumnDataType().getJavaSqlType().getJavaSqlType()) {
    case Types.VARCHAR: return JdbcType.VARCHAR;
    case Types.INTEGER: return JdbcType.INT;
    case Types.BIGINT: return JdbcType.BIGINT;
    case Types.CHAR: return JdbcType.CHAR;
    case Types.DATE: return JdbcType.DATE;
    case Types.TIMESTAMP: return JdbcType.TIMESTAMP;
    case Types.DECIMAL: return JdbcType.DECIMAL;
    case Types.NUMERIC: return JdbcType.DECIMAL;
    case Types.SMALLINT: return JdbcType.SMALLINT;
    case Types.BIT: return JdbcType.SMALLINT;
    case Types.BLOB: return JdbcType.BLOB;
    case Types.CLOB: return JdbcType.CLOB;
    case 2147483647: {
      JdbcType jt = getJdbcTypeForUnknownJavaSqlType(column);
      if (jt != null) {
        return jt;
      }
    }
    }
   throw new IllegalArgumentException("Unsupported column type " + column.getColumnDataType().getJavaSqlType() + " (" + column.getColumnDataType().getJavaSqlType().getJavaSqlType() + ")");
}
 
Example 5
Source File: JDBCAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public String dbRepresentation(int column, Object value) {
    int type;

    if (value == null) {
        return "null";
    }

    try {
        type = metaData.getColumnType(column + 1);
    } catch (SQLException e) {
        return value.toString();
    }

    switch (type) {
        case Types.INTEGER:
        case Types.DOUBLE:
        case Types.FLOAT:
            return value.toString();
        case Types.BIT:
            return ((Boolean) value).booleanValue() ? "1" : "0";
        case Types.DATE:
            return value.toString(); // This will need some conversion.
        default:
            return "\"" + value.toString() + "\"";
    }

}
 
Example 6
Source File: JdbcTypeUtil.java    From canal with Apache License 2.0 5 votes vote down vote up
public static Class<?> jdbcType2javaType(int jdbcType) {
    switch (jdbcType) {
        case Types.BIT:
        case Types.BOOLEAN:
            // return Boolean.class;
        case Types.TINYINT:
            return Byte.TYPE;
        case Types.SMALLINT:
            return Short.class;
        case Types.INTEGER:
            return Integer.class;
        case Types.BIGINT:
            return Long.class;
        case Types.DECIMAL:
        case Types.NUMERIC:
            return BigDecimal.class;
        case Types.REAL:
            return Float.class;
        case Types.FLOAT:
        case Types.DOUBLE:
            return Double.class;
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
            return String.class;
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
        case Types.BLOB:
            return byte[].class;
        case Types.DATE:
            return Date.class;
        case Types.TIME:
            return Time.class;
        case Types.TIMESTAMP:
            return Timestamp.class;
        default:
            return String.class;
    }
}
 
Example 7
Source File: TypeUtil.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * This method encodes a value with Phoenix data type. It begins
 * with checking whether an object is BINARY and makes a call to
 * {@link #castBytes(Object, PDataType)} to convery bytes to
 * targetPhoenixType
 * 
 * @param o
 * @param targetPhoenixType
 * @return Object
 */
public static Object castPigTypeToPhoenix(Object o, byte objectType, PDataType targetPhoenixType) {
	PDataType inferredPType = getType(o, objectType);
	
	if(inferredPType == null) {
		return null;
	}
	
	if(inferredPType == PDataType.VARBINARY && targetPhoenixType != PDataType.VARBINARY) {
		try {
			o = castBytes(o, targetPhoenixType);
			inferredPType = getType(o, DataType.findType(o));
		} catch (IOException e) {
			throw new RuntimeException("Error while casting bytes for object " +o);
		}
	}

	if(inferredPType == PDataType.DATE) {
		int inferredSqlType = targetPhoenixType.getSqlType();

		if(inferredSqlType == Types.DATE) {
			return new Date(((DateTime)o).getMillis());
		} 
		if(inferredSqlType == Types.TIME) {
			return new Time(((DateTime)o).getMillis());
		}
		if(inferredSqlType == Types.TIMESTAMP) {
			return new Timestamp(((DateTime)o).getMillis());
		}
	}
	
	if (targetPhoenixType == inferredPType || inferredPType.isCoercibleTo(targetPhoenixType)) {
		return inferredPType.toObject(o, targetPhoenixType);
	}
	
	throw new RuntimeException(o.getClass().getName()
			+ " cannot be coerced to "+targetPhoenixType.toString());
}
 
Example 8
Source File: ResultSetUtil.java    From tajo with Apache License 2.0 5 votes vote down vote up
public static int columnScale(int columnType) throws SQLException {

    switch (columnType) {
    case Types.BOOLEAN:
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    case Types.BIGINT:
    case Types.DATE:
    case Types.BIT:
    case Types.BLOB:
    case Types.BINARY:
    case Types.ARRAY:
    case Types.STRUCT:
    case Types.NULL:
      return 0;
    case Types.FLOAT:
      return 7;
    case Types.DOUBLE:
      return 15;
    case Types.TIME:
    case Types.TIMESTAMP:
      return 9;
    case Types.DECIMAL:
      return Integer.MAX_VALUE;
    default:
      throw new SQLException("Invalid column type: " + columnType);
    }
  }
 
Example 9
Source File: Oracle8iDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String getSelectClauseNullString(int sqlType) {
	switch(sqlType) {
		case Types.VARCHAR:
		case Types.CHAR:
			return "to_char(null)";
		case Types.DATE:
		case Types.TIMESTAMP:
		case Types.TIME:
			return "to_date(null)";
		default:
			return "to_number(null)";
	}
}
 
Example 10
Source File: DB2LengthOperatorNode.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
private int getConstantLength( ) throws StandardException
  {
      DataTypeDescriptor typeDescriptor = operand.getTypeServices();
      
      switch( typeDescriptor.getJDBCTypeId())
      {
      case Types.BIGINT:
          return 8;
case Types.BOOLEAN:
      case Types.BIT:
          return 1;
      case Types.BINARY:
      case Types.CHAR:
          return typeDescriptor.getMaximumWidth();
      case Types.DATE:
          return 4;
      case Types.DECIMAL:
      case Types.NUMERIC:
          return typeDescriptor.getPrecision()/2 + 1;
      case Types.DOUBLE:
          return 8;
      case Types.FLOAT:
      case Types.REAL:
      case Types.INTEGER:
          return 4;
      case Types.SMALLINT:
          return 2;
      case Types.TIME:
          return 3;
      case Types.TIMESTAMP:
          return 10;
      case Types.TINYINT:
          return 1;
      case Types.LONGVARCHAR:
      case Types.VARCHAR:
      case Types.LONGVARBINARY:
      case Types.VARBINARY:
      case Types.BLOB:
          return getConstantNodeLength();
      default:
	return -1;
      }
  }
 
Example 11
Source File: JDBCExecutor.java    From amforeas with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Utility method which registers in a CallableStatement object the different {@link amforeas.jdbc.StoredProcedureParam}
 * instances in the given list. Returns a List of {@link amforeas.jdbc.StoredProcedureParam} with all the OUT parameters
 * registered in the CallableStatement
 * @param cs the CallableStatement object where the parameters are registered.
 * @param params a list of {@link amforeas.jdbc.StoredProcedureParam}
 * @return a list of OUT {@link amforeas.jdbc.StoredProcedureParam} 
 * @throws SQLException if we fail to register any of the parameters in the CallableStatement
 * @throws AmforeasBadRequestException 
 */
private List<StoredProcedureParam> addParameters (final CallableStatement cs, final List<StoredProcedureParam> params) throws SQLException, AmforeasBadRequestException {
    final List<StoredProcedureParam> outParams = new ArrayList<StoredProcedureParam>();
    int i = 1;
    for (StoredProcedureParam p : params) {
        final Integer sqlType = p.getSqlType();
        if (p.isOutParameter()) {
            l.debug("Adding OUT parameter " + p.toString());
            cs.registerOutParameter(i++, sqlType);
            outParams.add(p);
        } else {
            l.debug("Adding IN parameter " + p.toString());
            switch (sqlType) {
                case Types.BIGINT:
                case Types.INTEGER:
                case Types.TINYINT:
                    // case Types.NUMERIC:
                    cs.setInt(i++, Integer.valueOf(p.getValue()));
                    break;
                case Types.DATE:
                    cs.setDate(i++, (Date) AmforeasUtils.parseValue(p.getValue()));
                    break;
                case Types.TIME:
                    cs.setTime(i++, (Time) AmforeasUtils.parseValue(p.getValue()));
                    break;
                case Types.TIMESTAMP:
                    cs.setTimestamp(i++, (Timestamp) AmforeasUtils.parseValue(p.getValue()));
                    break;
                case Types.DECIMAL:
                    cs.setBigDecimal(i++, (BigDecimal) AmforeasUtils.parseValue(p.getValue()));
                    break;
                case Types.DOUBLE:
                    cs.setDouble(i++, Double.valueOf(p.getValue()));
                    break;
                case Types.FLOAT:
                    cs.setLong(i++, Long.valueOf(p.getValue()));
                    break;
                default:
                    cs.setString(i++, p.getValue());
                    break;
            }
        }
    }
    return outParams;
}
 
Example 12
Source File: SqlTypeSide.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
public static int getSqlType(String s) {
	switch (s.toLowerCase()) {
	case "varbinary":
		return Types.VARBINARY;
	case "longvarbinary":
		return Types.LONGVARBINARY;
	case "binary":
		return Types.BINARY;
	case "date":
		return Types.DATE;
	case "time":
		return Types.TIME;
	case "timestamp":
		return Types.TIMESTAMP;
	case "bigint":
		return Types.BIGINT;
	case "boolean":
		return Types.BOOLEAN;
	case "char":
		return Types.CHAR;
	case "double":
		return Types.DOUBLE;
	case "doubleprecision":
		return Types.DOUBLE;
	case "numeric":
		return Types.NUMERIC;
	case "decimal":
		return Types.DECIMAL;
	case "real":
		return Types.REAL;
	case "float":
		return Types.FLOAT;
	case "integer":
		return Types.INTEGER;
	case "tinyint":
		return Types.TINYINT;
	case "bit":
		return Types.BIT;
	case "smallint":
		return Types.SMALLINT;
	case "nvarchar":
		return Types.NVARCHAR;
	case "longvarchar":
		return Types.LONGVARCHAR;
	case "text":
		return Types.VARCHAR;
	case "varchar":
		return Types.VARCHAR;
	case "string":
		return Types.VARCHAR;
	case "blob":
		return Types.BLOB;
	case "other":
		return Types.OTHER;
	case "clob":
		return Types.CLOB;
	// case "long": return Types.Lo
	}
	// Types.
	throw new RuntimeException("Unknown sql type: " + s);
}
 
Example 13
Source File: KylinClient.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public static Object wrapObject(String value, int sqlType) {
    if (null == value) {
        return null;
    }

    switch (sqlType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return value;
    case Types.NUMERIC:
    case Types.DECIMAL:
        return new BigDecimal(value);
    case Types.BIT:
    case Types.BOOLEAN:
        return Boolean.valueOf(value);
    case Types.TINYINT:
        return Byte.valueOf(value);
    case Types.SMALLINT:
        return Short.valueOf(value);
    case Types.INTEGER:
        return Integer.valueOf(value);
    case Types.BIGINT:
        return Long.valueOf(value);
    case Types.FLOAT:
        return Float.valueOf(value);
    case Types.REAL:
    case Types.DOUBLE:
        return Double.valueOf(value);
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return value.getBytes(StandardCharsets.UTF_8);
    case Types.DATE:
        return dateConvert(value);
    case Types.TIME:
        return Time.valueOf(value);
    case Types.TIMESTAMP:
        return timestampConvert(value);
    default:
        //do nothing
        break;

    }

    return value;
}
 
Example 14
Source File: ResultConvertUtils.java    From dts with Apache License 2.0 4 votes vote down vote up
private static Object getDataByType(int index, int columnType, ResultSet resultSet) throws SQLException {
    if (columnType == Types.BIT) {
        return resultSet.getByte(index);
    }
    if (columnType == Types.TINYINT) {
        return resultSet.getByte(index);
    }
    if (columnType == Types.SMALLINT) {
        return resultSet.getShort(index);
    }
    if (columnType == Types.INTEGER) {
        return resultSet.getInt(index);
    }
    if (columnType == Types.BIGINT) {
        return resultSet.getLong(index);
    }
    if (columnType == Types.FLOAT) {
        return resultSet.getFloat(index);
    }
    if (columnType == Types.DOUBLE) {
        return resultSet.getDouble(index);
    }
    if (columnType == Types.NUMERIC) {
        return resultSet.getInt(index);
    }
    if (columnType == Types.DECIMAL) {
        return resultSet.getBigDecimal(index);
    }
    if (columnType == Types.CHAR) {
        return resultSet.getString(index);
    }
    if (columnType == Types.VARCHAR) {
        return resultSet.getString(index);
    }
    if (columnType == Types.LONGNVARCHAR) {
        return resultSet.getString(index);
    }
    if (columnType == Types.DATE) {
        return resultSet.getDate(index);
    }
    if (columnType == Types.TIME) {
        return resultSet.getTime(index);
    }
    if (columnType == Types.NCHAR) {
        return resultSet.getNString(index);
    }
    if (columnType == Types.NVARCHAR) {
        return resultSet.getNString(index);
    }
    if (columnType == Types.OTHER) {
        return resultSet.getObject(index);
    }
    if (columnType == Types.BLOB) {
        return resultSet.getBlob(index);
    }
    if (columnType == Types.BOOLEAN) {
        return resultSet.getBoolean(index);
    }
    if (columnType == Types.ARRAY) {
        return resultSet.getArray(index);
    }
    if (columnType == Types.TIMESTAMP) {
        return resultSet.getTimestamp(index);
    }
    return resultSet.getObject(index);
}
 
Example 15
Source File: ConnManager.java    From aliyun-maxcompute-data-collectors with Apache License 2.0 4 votes vote down vote up
/**
 * Resolve a database-specific type to Avro data type.
 * @param sqlType     sql type
 * @return            avro type
 */
public Type toAvroType(int sqlType) {
  switch (sqlType) {
  case Types.TINYINT:
  case Types.SMALLINT:
  case Types.INTEGER:
    return Type.INT;
  case Types.BIGINT:
    return Type.LONG;
  case Types.BIT:
  case Types.BOOLEAN:
    return Type.BOOLEAN;
  case Types.REAL:
    return Type.FLOAT;
  case Types.FLOAT:
  case Types.DOUBLE:
    return Type.DOUBLE;
  case Types.NUMERIC:
  case Types.DECIMAL:
    return Type.STRING;
  case Types.CHAR:
  case Types.VARCHAR:
  case Types.LONGVARCHAR:
  case Types.LONGNVARCHAR:
  case Types.NVARCHAR:
  case Types.NCHAR:
    return Type.STRING;
  case Types.DATE:
  case Types.TIME:
  case Types.TIMESTAMP:
    return Type.LONG;
  case Types.BLOB:
  case Types.BINARY:
  case Types.VARBINARY:
  case Types.LONGVARBINARY:
    return Type.BYTES;
  default:
    throw new IllegalArgumentException("Cannot convert SQL type "
        + sqlType);
  }
}
 
Example 16
Source File: MSSqlBuilder.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected String getValueAsString(Column column, Object value)
{
    if (value == null)
    {
        return "NULL";
    }

    StringBuilder result = new StringBuilder();

    switch (column.getTypeCode())
    {
        case Types.REAL:
        case Types.NUMERIC:
        case Types.FLOAT:
        case Types.DOUBLE:
        case Types.DECIMAL:
            // SQL Server does not want quotes around the value
            if (!(value instanceof String) && (getValueNumberFormat() != null))
            {
                result.append(getValueNumberFormat().format(value));
            }
            else
            {
                result.append(value.toString());
            }
            break;
        case Types.DATE:
            result.append("CAST(");
            result.append(getPlatformInfo().getValueQuoteToken());
            result.append(value instanceof String ? (String)value : getValueDateFormat().format(value));
            result.append(getPlatformInfo().getValueQuoteToken());
            result.append(" AS datetime)");
            break;
        case Types.TIME:
            result.append("CAST(");
            result.append(getPlatformInfo().getValueQuoteToken());
            result.append(value instanceof String ? (String)value : getValueTimeFormat().format(value));
            result.append(getPlatformInfo().getValueQuoteToken());
            result.append(" AS datetime)");
            break;
        case Types.TIMESTAMP:
            result.append("CAST(");
            result.append(getPlatformInfo().getValueQuoteToken());
            result.append(value.toString());
            result.append(getPlatformInfo().getValueQuoteToken());
            result.append(" AS datetime)");
            break;
    }
    return super.getValueAsString(column, value);
}
 
Example 17
Source File: TypeDate.java    From antsdb with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TypeDate(String name) {
	super(name, 0, 0, Types.DATE, Date.class, Value.TYPE_DATE, Weight.DATE);
}
 
Example 18
Source File: DataTypeDescriptor.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Compare JdbcTypeIds to determine if they represent equivalent
 * SQL types. For example Types.NUMERIC and Types.DECIMAL are
 * equivalent
 *
 * @param existingType JDBC type id of Derby data type
 * @param jdbcTypeId   JDBC type id passed in from application.
 * @return boolean true if types are equivalent, false if not
 */

public static boolean isJDBCTypeEquivalent(int existingType,int jdbcTypeId){
    // Any type matches itself.
    if(existingType==jdbcTypeId)
        return true;

    // To a numeric type
    if(DataTypeDescriptor.isNumericType(existingType)){
        return DataTypeDescriptor.isNumericType(jdbcTypeId) || DataTypeDescriptor.isCharacterType(jdbcTypeId);
    }

    // To character type.
    if(DataTypeDescriptor.isCharacterType(existingType)){

        if(DataTypeDescriptor.isCharacterType(jdbcTypeId))
            return true;

        if(DataTypeDescriptor.isNumericType(jdbcTypeId))
            return true;


        switch(jdbcTypeId){
            case Types.DATE:
            case Types.TIME:
            case Types.TIMESTAMP:
                return true;
            default:
                break;
        }


        return false;

    }

    // To binary type
    if(DataTypeDescriptor.isBinaryType(existingType)){
        return DataTypeDescriptor.isBinaryType(jdbcTypeId);
    }

    // To DATE, TIME
    if(existingType==Types.DATE || existingType==Types.TIME){
        return DataTypeDescriptor.isCharacterType(jdbcTypeId) || jdbcTypeId==Types.TIMESTAMP;
    }

    // To TIMESTAMP
    if(existingType==Types.TIMESTAMP){
        return DataTypeDescriptor.isCharacterType(jdbcTypeId) || jdbcTypeId==Types.DATE;
    }

    // To CLOB
    return existingType==Types.CLOB && DataTypeDescriptor.isCharacterType(jdbcTypeId);
}
 
Example 19
Source File: DatabaseMetaDataTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Given a valid SQL type return the corresponding
 * JDBC type identifier from java.sql.Types.
 * Will assert if the type is not known
 * (in future, currently just return Types.NULL).
 */
public static int getJDBCType(String type)
{
    if ("SMALLINT".equals(type))
        return Types.SMALLINT;
    if ("INTEGER".equals(type) || "INT".equals(type))
        return Types.INTEGER;
    if ("BIGINT".equals(type))
        return Types.BIGINT;

    if (type.equals("FLOAT") || type.startsWith("FLOAT("))
        return Types.FLOAT;
    if (type.equals("REAL"))
        return Types.REAL;

    if ("DOUBLE".equals(type) || "DOUBLE PRECISION".equals(type))
        return Types.DOUBLE;

    if ("DATE".equals(type))
        return Types.DATE;
    if ("TIME".equals(type))
        return Types.TIME;
    if ("TIMESTAMP".equals(type))
        return Types.TIMESTAMP;

    if (type.equals("DECIMAL") || type.startsWith("DECIMAL("))
        return Types.DECIMAL;
    if (type.equals("NUMERIC") || type.startsWith("NUMERIC("))
        return Types.NUMERIC;

    if (type.endsWith("FOR BIT DATA")) {
       if (type.startsWith("CHAR"))
           return Types.BINARY;
       if (type.startsWith("CHARACTER"))
        return Types.BINARY;

       if (type.startsWith("VARCHAR"))
           return Types.VARBINARY;
       if (type.startsWith("CHARACTER VARYING"))
           return Types.VARBINARY;
       if (type.startsWith("CHAR VARYING"))
           return Types.VARBINARY;
    }

    if ("LONG VARCHAR".equals(type))
        return Types.LONGVARCHAR;
    if ("LONG VARCHAR FOR BIT DATA".equals(type))
        return Types.LONGVARBINARY;

    if (type.equals("CHAR") || type.startsWith("CHAR("))
        return Types.CHAR;
    if (type.equals("CHARACTER") ||
            type.startsWith("CHARACTER("))
        return Types.CHAR;

    if (type.equals("VARCHAR") || type.startsWith("VARCHAR("))
        return Types.VARCHAR;
    if (type.equals("CHARACTER VARYING") ||
            type.startsWith("CHARACTER VARYING("))
        return Types.VARCHAR;
    if (type.equals("CHAR VARYING") ||
            type.startsWith("CHAR VARYING("))
        return Types.VARCHAR;

    if (type.equals("BLOB") || type.startsWith("BLOB("))
        return Types.BLOB;
    if (type.equals("BINARY LARGE OBJECT") ||
            type.startsWith("BINARY LARGE OBJECT("))
        return Types.BLOB;

    if (type.equals("CLOB") || type.startsWith("CLOB("))
        return Types.CLOB;
    if (type.equals("CHARACTER LARGE OBJECT") ||
            type.startsWith("CHARACTER LARGE OBJECT("))
        return Types.CLOB;

    if ("XML".equals(type))
        return JDBC.SQLXML;

    fail("Unexpected SQL type: " + type);
    return Types.NULL;
}
 
Example 20
Source File: DateType.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public int sqlType() {
	return Types.DATE;
}