Java Code Examples for java.sql.Types#NCLOB

The following examples show how to use java.sql.Types#NCLOB . 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: AbstractHANADialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) {
	switch ( sqlCode ) {
		case Types.CLOB:
			return this.clobTypeDescriptor;
		case Types.NCLOB:
			return this.nClobTypeDescriptor;
		case Types.BLOB:
			return this.blobTypeDescriptor;
		case Types.TINYINT:
			// tinyint is unsigned on HANA
			return SmallIntTypeDescriptor.INSTANCE;
		case Types.BOOLEAN:
			return this.useLegacyBooleanType ? BitTypeDescriptor.INSTANCE : BooleanTypeDescriptor.INSTANCE;
		case Types.VARCHAR:
			return this.useUnicodeStringTypes ? NVarcharTypeDescriptor.INSTANCE : VarcharTypeDescriptor.INSTANCE;
		case Types.CHAR:
			return this.useUnicodeStringTypes ? NCharTypeDescriptor.INSTANCE : CharTypeDescriptor.INSTANCE;
		default:
			return super.getSqlTypeDescriptorOverride( sqlCode );
	}
}
 
Example 2
Source File: DB297Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	// See HHH-12753
	// It seems that DB2's JDBC 4.0 support as of 9.5 does not support the N-variant methods like
	// NClob or NString.  Therefore here we overwrite the sql type descriptors to use the non-N variants
	// which are supported.
	switch ( sqlCode ) {
		case Types.NCHAR:
			return CharTypeDescriptor.INSTANCE;

		case Types.NCLOB:
			if ( useInputStreamToInsertBlob() ) {
				return ClobTypeDescriptor.STREAM_BINDING;
			}
			else {
				return ClobTypeDescriptor.CLOB_BINDING;
			}

		case Types.NVARCHAR:
			return VarcharTypeDescriptor.INSTANCE;

		default:
			return super.getSqlTypeDescriptorOverride( sqlCode );
	}
}
 
Example 3
Source File: OracleColumnMetadataReader.java    From virtual-schemas with MIT License 6 votes vote down vote up
@Override
public DataType mapJdbcType(final JdbcTypeDescription jdbcTypeDescription) {
    switch (jdbcTypeDescription.getJdbcType()) {
    case Types.DECIMAL:
    case Types.NUMERIC:
        return mapNumericType(jdbcTypeDescription);
    case ORACLE_TIMESTAMP_WITH_TIME_ZONE:
    case ORACLE_TIMESTAMP_WITH_LOCAL_TIME_ZONE:
        return DataType.createTimestamp(false);
    case Types.NCLOB:
    case ORACLE_CLOB:
    case INTERVAL_YEAR_TO_MONTH:
    case INTERVAL_DAY_TO_SECOND:
    case ORACLE_BINARY_FLOAT:
    case ORACLE_BINARY_DOUBLE:
    case Types.ROWID:
        return DataType.createMaximumSizeVarChar(DataType.ExaCharset.UTF8);
    case Types.BLOB:
        return mapBlobType();
    default:
        return super.mapJdbcType(jdbcTypeDescription);
    }
}
 
Example 4
Source File: YuGongUtils.java    From yugong with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isClobType(int sqlType) {
    if (sqlType == Types.CLOB || sqlType == Types.LONGVARCHAR || sqlType == Types.NCLOB
        || sqlType == Types.LONGNVARCHAR) {
        return true;
    } else {
        return false;
    }
}
 
Example 5
Source File: DatabaseMetaDataProvider.java    From morf with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a given SQL data type to a {@link DataType}.
 *
 * @param typeCode JDBC data type.
 * @param typeName JDBC type name.
 * @param width JDBC column size.
 * @return Morf data type.
 */
protected DataType dataTypeFromSqlType(int typeCode, String typeName, int width) {
  switch (typeCode) {
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
      return DataType.INTEGER;
    case Types.BIGINT:
      return DataType.BIG_INTEGER;
    case Types.FLOAT:
    case Types.REAL:
    case Types.DOUBLE:
    case Types.NUMERIC:
    case Types.DECIMAL:
      return DataType.DECIMAL;
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
    case Types.NVARCHAR:
      return DataType.STRING;
    case Types.BOOLEAN:
    case Types.BIT:
      return DataType.BOOLEAN;
    case Types.DATE:
      return DataType.DATE;
    case Types.BLOB:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
      return DataType.BLOB;
    case Types.NCLOB:
    case Types.CLOB:
      return DataType.CLOB;
    default:
      throw new UnexpectedDataTypeException("Unsupported data type [" + typeName + "] (type " + typeCode + " width " + width + ")");
  }
}
 
Example 6
Source File: ValueBinderExpressionVisitorAdapter.java    From spanner-jdbc with MIT License 4 votes vote down vote up
private R setNullValue(Integer sqlType) {
  if (sqlType == null) {
    return binder.to((String) null);
  }
  switch (sqlType) {
    case Types.BIGINT:
      return binder.to((Long) null);
    case Types.BINARY:
      return binder.to((ByteArray) null);
    case Types.BLOB:
      return binder.to((ByteArray) null);
    case Types.BOOLEAN:
      return binder.to((Boolean) null);
    case Types.CHAR:
      return binder.to((String) null);
    case Types.CLOB:
      return binder.to((String) null);
    case Types.DATE:
      return binder.to((com.google.cloud.Date) null);
    case Types.DECIMAL:
      return binder.to((Double) null);
    case Types.DOUBLE:
      return binder.to((Double) null);
    case Types.FLOAT:
      return binder.to((Double) null);
    case Types.INTEGER:
      return binder.to((Long) null);
    case Types.LONGNVARCHAR:
      return binder.to((String) null);
    case Types.LONGVARBINARY:
      return binder.to((ByteArray) null);
    case Types.LONGVARCHAR:
      return binder.to((String) null);
    case Types.NCHAR:
      return binder.to((String) null);
    case Types.NCLOB:
      return binder.to((String) null);
    case Types.NUMERIC:
      return binder.to((Double) null);
    case Types.NVARCHAR:
      return binder.to((String) null);
    case Types.REAL:
      return binder.to((Double) null);
    case Types.SMALLINT:
      return binder.to((Long) null);
    case Types.SQLXML:
      return binder.to((String) null);
    case Types.TIME:
      return binder.to((com.google.cloud.Timestamp) null);
    case Types.TIMESTAMP:
      return binder.to((com.google.cloud.Timestamp) null);
    case Types.TINYINT:
      return binder.to((Long) null);
    case Types.VARBINARY:
      return binder.to((ByteArray) null);
    case Types.VARCHAR:
      return binder.to((String) null);
    default:
      throw new IllegalArgumentException("Unsupported sql type for setting to null: " + sqlType);
  }
}
 
Example 7
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get JDBC {@link Types} type for given {@link GFXDType}.
 */
public static int getJdbcType(GFXDType type) {
  switch (type) {
    case ARRAY:
      return Types.ARRAY;
    case BIGINT:
      return Types.BIGINT;
    case BINARY:
      return Types.BINARY;
    case BLOB:
      return Types.BLOB;
    case BOOLEAN:
      return Types.BOOLEAN;
    case CHAR:
      return Types.CHAR;
    case CLOB:
      return Types.CLOB;
    case DATALINK:
      return Types.DATALINK;
    case DATE:
      return Types.DATE;
    case DECIMAL:
      return Types.DECIMAL;
    case DISTINCT:
      return Types.DISTINCT;
    case DOUBLE:
      return Types.DOUBLE;
    case FLOAT:
      return Types.FLOAT;
    case INTEGER:
      return Types.INTEGER;
    case JAVA_OBJECT:
      return Types.JAVA_OBJECT;
    case JSON_OBJECT:
      return TYPE_JSON_OBJECT;
    case LONGNVARCHAR:
      return Types.LONGNVARCHAR;
    case LONGVARBINARY:
      return Types.LONGVARBINARY;
    case LONGVARCHAR:
      return Types.LONGVARCHAR;
    case NCHAR:
      return Types.NCHAR;
    case NCLOB:
      return Types.NCLOB;
    case NULLTYPE:
      return Types.NULL;
    case NVARCHAR:
      return Types.NVARCHAR;
    case OTHER:
      return Types.OTHER;
    case PDX_OBJECT:
      return TYPE_PDX_OBJECT;
    case REAL:
      return Types.REAL;
    case REF:
      return Types.REF;
    case ROWID:
      return Types.ROWID;
    case SMALLINT:
      return Types.SMALLINT;
    case SQLXML:
      return Types.SQLXML;
    case STRUCT:
      return Types.STRUCT;
    case TIME:
      return Types.TIME;
    case TIMESTAMP:
      return Types.TIMESTAMP;
    case TINYINT:
      return Types.TINYINT;
    case VARBINARY:
      return Types.VARBINARY;
    case VARCHAR:
      return Types.VARCHAR;
    default:
      return Types.OTHER;
  }
}
 
Example 8
Source File: JDBCUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Get the SQLType for the given java.sql.Type type.
 *
 * @param type the java.sql.Type type specifier
 * @return SQLType.the SQLType for this java.sql.Type, or null if it's not recognized
 */
public static SQLType getSQLType(int type) {
    switch (type) {
        case Types.BIT: return SQLType.BIT;
        case Types.TINYINT: return SQLType.TINYINT;
        case Types.SMALLINT: return SQLType.SMALLINT;
        case Types.INTEGER: return SQLType.INTEGER;
        case Types.BIGINT: return SQLType.BIGINT;
        case Types.FLOAT: return SQLType.FLOAT;
        case Types.REAL: return SQLType.REAL;
        case Types.DOUBLE: return SQLType.DOUBLE;
        case Types.NUMERIC: return SQLType.NUMERIC;
        case Types.DECIMAL: return SQLType.DECIMAL;
        case Types.CHAR: return SQLType.CHAR;
        case Types.VARCHAR: return SQLType.VARCHAR;
        case Types.LONGVARCHAR: return SQLType.LONGVARCHAR;
        case Types.DATE: return SQLType.DATE;
        case Types.TIME: return SQLType.TIME;
        case Types.TIMESTAMP: return SQLType.TIMESTAMP;
        case Types.BINARY: return SQLType.BINARY;
        case Types.VARBINARY: return SQLType.VARBINARY;
        case Types.LONGVARBINARY: return SQLType.LONGVARBINARY;
        case Types.NULL: return SQLType.NULL;
        case Types.OTHER: return SQLType.OTHER;
        case Types.JAVA_OBJECT: return SQLType.JAVA_OBJECT;
        case Types.DISTINCT: return SQLType.DISTINCT;
        case Types.STRUCT: return SQLType.STRUCT;
        case Types.ARRAY: return SQLType.ARRAY;
        case Types.BLOB: return SQLType.BLOB;
        case Types.CLOB: return SQLType.CLOB;
        case Types.REF: return SQLType.REF;
        case Types.DATALINK: return SQLType.DATALINK;
        case Types.BOOLEAN: return SQLType.BOOLEAN;
        case Types.LONGNVARCHAR: return SQLType.LONGVARCHAR;
        case Types.NCHAR: return SQLType.CHAR;
        case Types.NCLOB: return SQLType.CLOB;
        case Types.NVARCHAR: return SQLType.VARCHAR;
        case Types.SQLXML: return SQLType.SQLXML;
        case Types.ROWID: return SQLType.ROWID;
        default:
            Logger.getLogger(JDBCUtils.class.getName()).log(Level.WARNING, "Unknown JDBC column type: " + type + ". Returns null.");
            return null;
    }
}
 
Example 9
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get JDBC {@link Types} type for given {@link GFXDType}.
 */
public static int getJdbcType(GFXDType type) {
  switch (type) {
    case ARRAY:
      return Types.ARRAY;
    case BIGINT:
      return Types.BIGINT;
    case BINARY:
      return Types.BINARY;
    case BLOB:
      return Types.BLOB;
    case BOOLEAN:
      return Types.BOOLEAN;
    case CHAR:
      return Types.CHAR;
    case CLOB:
      return Types.CLOB;
    case DATALINK:
      return Types.DATALINK;
    case DATE:
      return Types.DATE;
    case DECIMAL:
      return Types.DECIMAL;
    case DISTINCT:
      return Types.DISTINCT;
    case DOUBLE:
      return Types.DOUBLE;
    case FLOAT:
      return Types.FLOAT;
    case INTEGER:
      return Types.INTEGER;
    case JAVA_OBJECT:
      return Types.JAVA_OBJECT;
    case JSON_OBJECT:
      return TYPE_JSON_OBJECT;
    case LONGNVARCHAR:
      return Types.LONGNVARCHAR;
    case LONGVARBINARY:
      return Types.LONGVARBINARY;
    case LONGVARCHAR:
      return Types.LONGVARCHAR;
    case NCHAR:
      return Types.NCHAR;
    case NCLOB:
      return Types.NCLOB;
    case NULLTYPE:
      return Types.NULL;
    case NVARCHAR:
      return Types.NVARCHAR;
    case OTHER:
      return Types.OTHER;
    case PDX_OBJECT:
      return TYPE_PDX_OBJECT;
    case REAL:
      return Types.REAL;
    case REF:
      return Types.REF;
    case ROWID:
      return Types.ROWID;
    case SMALLINT:
      return Types.SMALLINT;
    case SQLXML:
      return Types.SQLXML;
    case STRUCT:
      return Types.STRUCT;
    case TIME:
      return Types.TIME;
    case TIMESTAMP:
      return Types.TIMESTAMP;
    case TINYINT:
      return Types.TINYINT;
    case VARBINARY:
      return Types.VARBINARY;
    case VARCHAR:
      return Types.VARCHAR;
    default:
      return Types.OTHER;
  }
}
 
Example 10
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get {@link GFXDType} for given JDBC {@link Types}.
 */
public static GFXDType getThriftSQLType(int jdbcType) {
  switch (jdbcType) {
    case Types.ARRAY:
      return GFXDType.ARRAY;
    case Types.BIGINT:
      return GFXDType.BIGINT;
    case Types.BINARY:
      return GFXDType.BINARY;
    case Types.BIT:
      return GFXDType.BOOLEAN;
    case Types.BLOB:
      return GFXDType.BLOB;
    case Types.BOOLEAN:
      return GFXDType.BOOLEAN;
    case Types.CHAR:
      return GFXDType.CHAR;
    case Types.CLOB:
      return GFXDType.CLOB;
    case Types.DATALINK:
      return GFXDType.DATALINK;
    case Types.DATE:
      return GFXDType.DATE;
    case Types.DECIMAL:
      return GFXDType.DECIMAL;
    case Types.DISTINCT:
      return GFXDType.DISTINCT;
    case Types.DOUBLE:
      return GFXDType.DOUBLE;
    case Types.FLOAT:
      return GFXDType.FLOAT;
    case Types.INTEGER:
      return GFXDType.INTEGER;
    case Types.JAVA_OBJECT:
      return GFXDType.JAVA_OBJECT;
    case TYPE_JSON_OBJECT:
      return GFXDType.JSON_OBJECT;
    case Types.LONGNVARCHAR:
      return GFXDType.LONGNVARCHAR;
    case Types.LONGVARBINARY:
      return GFXDType.LONGVARBINARY;
    case Types.LONGVARCHAR:
      return GFXDType.LONGVARCHAR;
    case Types.NCHAR:
      return GFXDType.NCHAR;
    case Types.NCLOB:
      return GFXDType.NCLOB;
    case Types.NULL:
      return GFXDType.NULLTYPE;
    case Types.NUMERIC:
      return GFXDType.DECIMAL;
    case Types.NVARCHAR:
      return GFXDType.NVARCHAR;
    case Types.OTHER:
      return GFXDType.OTHER;
    case TYPE_PDX_OBJECT:
      return GFXDType.PDX_OBJECT;
    case Types.REAL:
      return GFXDType.REAL;
    case Types.REF:
      return GFXDType.REF;
    case Types.ROWID:
      return GFXDType.ROWID;
    case Types.SMALLINT:
      return GFXDType.SMALLINT;
    case Types.SQLXML:
      return GFXDType.SQLXML;
    case Types.STRUCT:
      return GFXDType.STRUCT;
    case Types.TIME:
      return GFXDType.TIME;
    case Types.TIMESTAMP:
      return GFXDType.TIMESTAMP;
    case Types.TINYINT:
      return GFXDType.TINYINT;
    case Types.VARBINARY:
      return GFXDType.VARBINARY;
    case Types.VARCHAR:
      return GFXDType.VARCHAR;
    default:
      return GFXDType.OTHER;
  }
}
 
Example 11
Source File: AbstractJdbcSpecific.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public char sqlType2jetel(int sqlType) {
	switch (sqlType) {
		case Types.INTEGER:
		case Types.SMALLINT:
		case Types.TINYINT:
			return DataFieldType.INTEGER.getShortName();
		//-------------------
		case Types.BIGINT:
			return DataFieldType.LONG.getShortName();
		//-------------------
		case Types.DECIMAL:
		case Types.NUMERIC:
			return DataFieldType.DECIMAL.getShortName();
		case Types.DOUBLE:
		case Types.FLOAT:
		case Types.REAL:
			return DataFieldType.NUMBER.getShortName();
		//------------------
		case Types.CHAR:
		case Types.LONGVARCHAR:
		case Types.VARCHAR:
		case Types.CLOB:
		case Types.NCHAR:
		case Types.NVARCHAR:
		case Types.NCLOB:
			return DataFieldType.STRING.getShortName();
		//------------------
		case Types.DATE:
		case Types.TIME:
		case Types.TIMESTAMP:
			return DataFieldType.DATE.getShortName();
           //-----------------
           case Types.BINARY:
           case Types.VARBINARY:
           case Types.LONGVARBINARY:
           case Types.BLOB:
		case Types.OTHER:
			return DataFieldType.BYTE.getShortName();
		//-----------------
		case Types.BOOLEAN:
			return DataFieldType.BOOLEAN.getShortName();
		// proximity assignment
		case Types.BIT:
		case Types.NULL:
			return DataFieldType.STRING.getShortName();
		case Types.STRUCT:
			throw new IllegalArgumentException("Can't handle JDBC type STRUCT");
		default:
			throw new IllegalArgumentException("Can't handle JDBC.Type :"+sqlType);
	}
}
 
Example 12
Source File: ParseUtil.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public static Field generateField(
    String column,
    String columnValue,
    int columnType,
    DateTimeColumnHandler dateTimeColumnHandler
) throws StageException {
  Field field;
  // All types as of JDBC 2.0 are here:
  // https://docs.oracle.com/javase/8/docs/api/constant-values.html#java.sql.Types.ARRAY
  // Good source of recommended mappings is here:
  // http://www.cs.mun.ca/java-api-1.5/guide/jdbc/getstart/mapping.html
  switch (columnType) {
    case Types.BIGINT:
      field = Field.create(Field.Type.LONG, columnValue);
      break;
    case Types.BINARY:
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
      field = Field.create(Field.Type.BYTE_ARRAY, RawTypeHandler.parseRaw(column, columnValue, columnType));
      break;
    case Types.BIT:
    case Types.BOOLEAN:
      field = Field.create(Field.Type.BOOLEAN, columnValue);
      break;
    case Types.CHAR:
    case Types.LONGNVARCHAR:
    case Types.LONGVARCHAR:
    case Types.NCHAR:
    case Types.NVARCHAR:
    case Types.VARCHAR:
      field = Field.create(Field.Type.STRING, columnValue);
      break;
    case Types.DECIMAL:
    case Types.NUMERIC:
      field = Field.create(Field.Type.DECIMAL, columnValue);
      break;
    case Types.DOUBLE:
      field = Field.create(Field.Type.DOUBLE, columnValue);
      break;
    case Types.FLOAT:
    case Types.REAL:
      field = Field.create(Field.Type.FLOAT, columnValue);
      break;
    case Types.INTEGER:
      field = Field.create(Field.Type.INTEGER, columnValue);
      break;
    case Types.SMALLINT:
    case Types.TINYINT:
      field = Field.create(Field.Type.SHORT, columnValue);
      break;
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
      field = dateTimeColumnHandler.getDateTimeStampField(column, columnValue, columnType);
      break;
    case Types.TIMESTAMP_WITH_TIMEZONE:
    case TIMESTAMP_TZ_TYPE:
      field = dateTimeColumnHandler.getTimestampWithTimezoneField(columnValue);
      break;
    case TIMESTAMP_LTZ_TYPE:
      field = dateTimeColumnHandler.getTimestampWithLocalTimezone(columnValue);
      break;
    case Types.ROWID:
    case Types.CLOB:
    case Types.NCLOB:
    case Types.BLOB:
    case Types.ARRAY:
    case Types.DATALINK:
    case Types.DISTINCT:
    case Types.JAVA_OBJECT:
    case Types.NULL:
    case Types.OTHER:
    case Types.REF:
    case Types.REF_CURSOR:
    case Types.SQLXML:
    case Types.STRUCT:
    case Types.TIME_WITH_TIMEZONE:
    default:
      throw new UnsupportedFieldTypeException(column, columnValue, columnType);
  }
  return field;
}
 
Example 13
Source File: NClobTypeDescriptor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getSqlType() {
	return Types.NCLOB;
}
 
Example 14
Source File: SqoopHCatUtilities.java    From aliyun-maxcompute-data-collectors with Apache License 2.0 4 votes vote down vote up
public static String sqlTypeString(int sqlType) {
  switch (sqlType) {
    case Types.BIT:
      return "BIT";
    case Types.TINYINT:
      return "TINYINT";
    case Types.SMALLINT:
      return "SMALLINT";
    case Types.INTEGER:
      return "INTEGER";
    case Types.BIGINT:
      return "BIGINT";
    case Types.FLOAT:
      return "FLOAT";
    case Types.REAL:
      return "REAL";
    case Types.DOUBLE:
      return "DOUBLE";
    case Types.NUMERIC:
      return "NUMERIC";
    case Types.DECIMAL:
      return "DECIMAL";
    case Types.CHAR:
      return "CHAR";
    case Types.VARCHAR:
      return "VARCHAR";
    case Types.LONGVARCHAR:
      return "LONGVARCHAR";
    case Types.DATE:
      return "DATE";
    case Types.TIME:
      return "TIME";
    case Types.TIMESTAMP:
      return "TIMESTAMP";
    case Types.BINARY:
      return "BINARY";
    case Types.VARBINARY:
      return "VARBINARY";
    case Types.LONGVARBINARY:
      return "LONGVARBINARY";
    case Types.NULL:
      return "NULL";
    case Types.OTHER:
      return "OTHER";
    case Types.JAVA_OBJECT:
      return "JAVA_OBJECT";
    case Types.DISTINCT:
      return "DISTINCT";
    case Types.STRUCT:
      return "STRUCT";
    case Types.ARRAY:
      return "ARRAY";
    case Types.BLOB:
      return "BLOB";
    case Types.CLOB:
      return "CLOB";
    case Types.REF:
      return "REF";
    case Types.DATALINK:
      return "DATALINK";
    case Types.BOOLEAN:
      return "BOOLEAN";
    case Types.ROWID:
      return "ROWID";
    case Types.NCHAR:
      return "NCHAR";
    case Types.NVARCHAR:
      return "NVARCHAR";
    case Types.LONGNVARCHAR:
      return "LONGNVARCHAR";
    case Types.NCLOB:
      return "NCLOB";
    case Types.SQLXML:
      return "SQLXML";
    default:
      return "<UNKNOWN>";
  }
}
 
Example 15
Source File: MysqlDefs.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
public static int javaTypeMysql(int javaType) {

		switch (javaType) {
		case Types.NUMERIC:
			return MysqlDefs.FIELD_TYPE_DECIMAL;

		case Types.DECIMAL:
			return MysqlDefs.FIELD_TYPE_NEW_DECIMAL;

		case Types.TINYINT:
			return MysqlDefs.FIELD_TYPE_TINY;

		case Types.SMALLINT:
			return MysqlDefs.FIELD_TYPE_SHORT;

		case Types.INTEGER:
			return MysqlDefs.FIELD_TYPE_LONG;

		case Types.REAL:
			return MysqlDefs.FIELD_TYPE_FLOAT;

		case Types.DOUBLE:
			return MysqlDefs.FIELD_TYPE_DOUBLE;

		case Types.NULL:
			return MysqlDefs.FIELD_TYPE_NULL;

		case Types.TIMESTAMP:
			return MysqlDefs.FIELD_TYPE_TIMESTAMP;

		case Types.BIGINT:
			return MysqlDefs.FIELD_TYPE_LONGLONG;

		case Types.DATE:
			return MysqlDefs.FIELD_TYPE_DATE;

		case Types.TIME:
			return MysqlDefs.FIELD_TYPE_TIME;

		case Types.VARBINARY:
			return MysqlDefs.FIELD_TYPE_TINY_BLOB;

		case Types.LONGVARBINARY:
			return MysqlDefs.FIELD_TYPE_BLOB;
            //对应sqlserver的image类型
            case 27:
                return MysqlDefs.FIELD_TYPE_BLOB;

		case Types.VARCHAR:
			return MysqlDefs.FIELD_TYPE_VAR_STRING;

		case Types.CHAR:
			return MysqlDefs.FIELD_TYPE_STRING;

		case Types.BINARY:
			return MysqlDefs.FIELD_TYPE_GEOMETRY;

		case Types.BIT:
			return MysqlDefs.FIELD_TYPE_BIT;
		case Types.CLOB:
			return MysqlDefs.FIELD_TYPE_VAR_STRING;
		case Types.BLOB:
			return MysqlDefs.FIELD_TYPE_BLOB;

		//修改by     [email protected]
		// 当jdbc连接非mysql的数据库时,需要把对应类型映射为mysql的类型,否则应用端会出错
			case Types.NVARCHAR:
				return MysqlDefs.FIELD_TYPE_VAR_STRING;
			case Types.NCHAR:
				return MysqlDefs.FIELD_TYPE_STRING;
			case Types.NCLOB:
				return MysqlDefs.FIELD_TYPE_VAR_STRING;
			case Types.LONGNVARCHAR:
				return MysqlDefs.FIELD_TYPE_VAR_STRING;

		default:
			return MysqlDefs.FIELD_TYPE_VAR_STRING;   //其他未知类型返回字符类型
		//	return Types.VARCHAR;
		}

	}
 
Example 16
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get {@link GFXDType} for given JDBC {@link Types}.
 */
public static GFXDType getThriftSQLType(int jdbcType) {
  switch (jdbcType) {
    case Types.ARRAY:
      return GFXDType.ARRAY;
    case Types.BIGINT:
      return GFXDType.BIGINT;
    case Types.BINARY:
      return GFXDType.BINARY;
    case Types.BIT:
      return GFXDType.BOOLEAN;
    case Types.BLOB:
      return GFXDType.BLOB;
    case Types.BOOLEAN:
      return GFXDType.BOOLEAN;
    case Types.CHAR:
      return GFXDType.CHAR;
    case Types.CLOB:
      return GFXDType.CLOB;
    case Types.DATALINK:
      return GFXDType.DATALINK;
    case Types.DATE:
      return GFXDType.DATE;
    case Types.DECIMAL:
      return GFXDType.DECIMAL;
    case Types.DISTINCT:
      return GFXDType.DISTINCT;
    case Types.DOUBLE:
      return GFXDType.DOUBLE;
    case Types.FLOAT:
      return GFXDType.FLOAT;
    case Types.INTEGER:
      return GFXDType.INTEGER;
    case Types.JAVA_OBJECT:
      return GFXDType.JAVA_OBJECT;
    case TYPE_JSON_OBJECT:
      return GFXDType.JSON_OBJECT;
    case Types.LONGNVARCHAR:
      return GFXDType.LONGNVARCHAR;
    case Types.LONGVARBINARY:
      return GFXDType.LONGVARBINARY;
    case Types.LONGVARCHAR:
      return GFXDType.LONGVARCHAR;
    case Types.NCHAR:
      return GFXDType.NCHAR;
    case Types.NCLOB:
      return GFXDType.NCLOB;
    case Types.NULL:
      return GFXDType.NULLTYPE;
    case Types.NUMERIC:
      return GFXDType.DECIMAL;
    case Types.NVARCHAR:
      return GFXDType.NVARCHAR;
    case Types.OTHER:
      return GFXDType.OTHER;
    case TYPE_PDX_OBJECT:
      return GFXDType.PDX_OBJECT;
    case Types.REAL:
      return GFXDType.REAL;
    case Types.REF:
      return GFXDType.REF;
    case Types.ROWID:
      return GFXDType.ROWID;
    case Types.SMALLINT:
      return GFXDType.SMALLINT;
    case Types.SQLXML:
      return GFXDType.SQLXML;
    case Types.STRUCT:
      return GFXDType.STRUCT;
    case Types.TIME:
      return GFXDType.TIME;
    case Types.TIMESTAMP:
      return GFXDType.TIMESTAMP;
    case Types.TINYINT:
      return GFXDType.TINYINT;
    case Types.VARBINARY:
      return GFXDType.VARBINARY;
    case Types.VARCHAR:
      return GFXDType.VARCHAR;
    default:
      return GFXDType.OTHER;
  }
}
 
Example 17
Source File: AttributeSetup.java    From celerio with Apache License 2.0 4 votes vote down vote up
private MappedType getRawMappedType() {
    switch (attribute.getJdbcType().getJdbcType()) {
        case Types.ARRAY:
            return M_ARRAY;
        case Types.BIGINT:
            return M_LONG;
        case Types.BINARY:
            return M_BYTES;
        case Types.BIT:
        case Types.BOOLEAN:
            return M_BOOLEAN;
        case Types.BLOB:
            return M_BLOB;
        case Types.CLOB:
        case Types.NCLOB:
        case Types.SQLXML:
            return M_CLOB;
        case Types.DATALINK:
            return M_URL;
        case Types.DATE:
            return M_UTILDATE;
        case Types.DISTINCT:
        case Types.JAVA_OBJECT:
            return M_OBJECT;
        case Types.DOUBLE:
        case Types.FLOAT:
            return M_DOUBLE;
        case Types.INTEGER:
        case Types.SMALLINT:
        case Types.TINYINT:
            return M_INTEGER;
        case Types.LONGVARBINARY:
            return M_BYTES;
        case Types.CHAR:
        case Types.LONGVARCHAR:
        case Types.VARCHAR:
        case Types.LONGNVARCHAR:
        case Types.NCHAR:
        case Types.NVARCHAR:
            return M_STRING;
        case Types.DECIMAL:
        case Types.NUMERIC:
            ColumnConfig column = attribute.getColumnConfig();
            if (column.getDecimalDigits() > 0) {
                if (column.getSize() < 11 && column.getDecimalDigits() < 4) {
                    return M_DOUBLE;
                } else {
                    return M_BIGDECIMAL;
                }
            } else {
                if (column.getSize() == 1 && IS_BOOLEAN_PREFIX.apply(attribute)) {
                    return M_BOOLEAN;
                } else {
                    if (column.getSize() < 11) {
                        return M_INTEGER;
                    } else if (column.getSize() < 19 || attribute.isInPk() || attribute.isInFk()) { // BIG INTEGER IS NOT
                        // ACCEPTED BY HIBERNATE
                        // FOR PK
                        return M_LONG;
                    } else {
                        return M_BIGINTEGER;
                    }
                }
            }
        case Types.OTHER:
            return M_OBJECT;
        case Types.REAL:
            return M_FLOAT;
        case Types.REF:
            return M_REF;
        case Types.STRUCT:
            return M_OBJECT;
        case Types.TIME:
        case Types.TIMESTAMP:
            return M_UTILDATE;
        case Types.VARBINARY:
            if (attribute.getColumnConfig().getSize() == 1) {
                return M_BYTE;
            } else {
                return M_BYTES;
            }
        case Types.ROWID:
            return M_LONG;
        default:
            throw new RuntimeException("Could not retrieve the type of " + this);
    }
}
 
Example 18
Source File: DatabaseStatement.java    From sndml3 with MIT License 4 votes vote down vote up
private static String sqlTypeName(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: return Integer.toString(sqltype);
	}
}
 
Example 19
Source File: SqlArgs.java    From database with Apache License 2.0 4 votes vote down vote up
@Nonnull
public SqlArgs read(Row r) {
  SqlArgs args = new SqlArgs();

  for (int i = 0; i < names.length; i++) {
    switch (types[i]) {
    case Types.SMALLINT:
    case Types.INTEGER:
      args.argInteger(names[i], r.getIntegerOrNull());
      break;
    case Types.BIGINT:
      args.argLong(names[i], r.getLongOrNull());
      break;
    case Types.REAL:
    case 100: // Oracle proprietary it seems
      args.argFloat(names[i], r.getFloatOrNull());
      break;
    case Types.DOUBLE:
    case 101: // Oracle proprietary it seems
      args.argDouble(names[i], r.getDoubleOrNull());
      break;
    case Types.NUMERIC:
      if (precision[i] == 10 && scale[i] == 0) {
        // Oracle reports integer as numeric
        args.argInteger(names[i], r.getIntegerOrNull());
      } else if (precision[i] == 19 && scale[i] == 0) {
        // Oracle reports long as numeric
        args.argLong(names[i], r.getLongOrNull());
      } else {
        args.argBigDecimal(names[i], r.getBigDecimalOrNull());
      }
      break;
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.BLOB:
      args.argBlobBytes(names[i], r.getBlobBytesOrNull());
      break;
    case Types.CLOB:
    case Types.NCLOB:
      args.argClobString(names[i], r.getClobStringOrNull());
      break;

    // Check Date before TimeStamp because SQL dates are also timestamps
    case Types.DATE:
        args.argLocalDate(names[i], r.getLocalDateOrNull());
        break;

    case Types.TIMESTAMP:
      if (this.scale[i] == 0) {
        // If the scale is 0, this is a LocalDate (no time/timezone).
        // Anything with a time will have a non-zero scale
        args.argLocalDate(names[i], r.getLocalDateOrNull());
      } else {
        args.argDate(names[i], r.getDateOrNull());
      }
      break;

    case Types.NVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
    case Types.NCHAR:
      if (precision[i] >= 2147483647) {
        // Postgres seems to report clobs are varchar(2147483647)
        args.argClobString(names[i], r.getClobStringOrNull());
      } else {
        args.argString(names[i], r.getStringOrNull());
      }
      break;
    default:
      throw new DatabaseException("Don't know how to deal with column type: " + types[i]);
    }
  }
  return args;
}
 
Example 20
Source File: TypeId.java    From Oceanus with Apache License 2.0 4 votes vote down vote up
/**
 * Get a TypeId of the given JDBC type.  This factory method is
 * intended to be used for built-in types.  For user-defined types,
 * we will need a factory method that takes a Java type name.
 *
 * @param JDBCTypeId The JDBC Id of the type, as listed in
 *                                   java.sql.Types
 *
 * @return The appropriate TypeId, or null if there is no such
 *               TypeId.
 */

public static TypeId getBuiltInTypeId(int JDBCTypeId) {

    switch (JDBCTypeId) {
    case Types.TINYINT:
        return TINYINT_ID;

    case Types.SMALLINT:
        return SMALLINT_ID;

    case Types.INTEGER:
        return INTEGER_ID;

    case Types.BIGINT:
        return BIGINT_ID;

    case Types.FLOAT:
    case Types.REAL:
        return REAL_ID;

    case Types.DOUBLE:
        return DOUBLE_ID;

    case Types.DECIMAL:
        return DECIMAL_ID;

    case Types.NUMERIC:
        return NUMERIC_ID;

    case Types.CHAR:
        return CHAR_ID;

    case Types.VARCHAR:
        return VARCHAR_ID;

    case Types.DATE:
        return DATE_ID;

    case Types.TIME:
        return TIME_ID;

    case Types.TIMESTAMP:
        return TIMESTAMP_ID;

    case Types.BIT:
    case Types.BOOLEAN:
        return BOOLEAN_ID;

    case Types.BINARY:
        return BIT_ID;

    case Types.VARBINARY:
        return VARBIT_ID;

    case Types.LONGVARBINARY:
        return LONGVARBIT_ID;

    case Types.LONGVARCHAR:
        return LONGVARCHAR_ID;

    case Types.BLOB:
        return BLOB_ID;

    case Types.CLOB:
        return CLOB_ID;

    case Types.SQLXML: // 2009
        return XML_ID;
                    
    case Types.NCHAR:
        return NATIONAL_CHAR_ID;

    case Types.NVARCHAR:
        return NATIONAL_VARCHAR_ID;

    case Types.NCLOB:
        return NATIONAL_LONGVARCHAR_ID;

    default:
        return null;
    }
}