本文整理汇总了Java中java.sql.Types.NCHAR属性的典型用法代码示例。如果您正苦于以下问题:Java Types.NCHAR属性的具体用法?Java Types.NCHAR怎么用?Java Types.NCHAR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.NCHAR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCharacter
/**
* Returns if the given data type is character type or not.
*
* @param type the type from java.sql.Types
* @return true if the given type is character type; false otherwise
*/
static public boolean isCharacter(int type) {
switch (type) {
case Types.BINARY:
case Types.CHAR:
case Types.LONGVARCHAR:
case Types.VARCHAR:
case Types.VARBINARY:
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
return true;
}
return false;
}
示例2: toHiveType
/**
* Given JDBC SQL types coming from another database, what is the best
* mapping to a Hive-specific type?
*/
public static String toHiveType(int sqlType) {
switch (sqlType) {
case Types.INTEGER:
case Types.SMALLINT:
return "INT";
case Types.VARCHAR:
case Types.CHAR:
case Types.LONGVARCHAR:
case Types.NVARCHAR:
case Types.NCHAR:
case Types.LONGNVARCHAR:
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
case Types.CLOB:
return "STRING";
case Types.NUMERIC:
case Types.DECIMAL:
case Types.FLOAT:
case Types.DOUBLE:
case Types.REAL:
return "DOUBLE";
case Types.BIT:
case Types.BOOLEAN:
return "BOOLEAN";
case Types.TINYINT:
return "TINYINT";
case Types.BIGINT:
return "BIGINT";
default:
// TODO(aaron): Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT,
// BLOB, ARRAY, STRUCT, REF, JAVA_OBJECT.
return null;
}
}
示例3: isTextType
public static boolean isTextType(int sqlType) {
if (sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.CLOB || sqlType == Types.LONGVARCHAR
|| sqlType == Types.NCHAR || sqlType == Types.NVARCHAR || sqlType == Types.NCLOB
|| sqlType == Types.LONGNVARCHAR) {
return true;
} else {
return false;
}
}
示例4: getSQLValue
public String getSQLValue(Table table, Row row, int index) {
Column column = table.getColumns().get(index);
int type = column.getDataType();
if (row.get(index) == null) {
return "null";
} else {
switch (type) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGNVARCHAR:
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGVARCHAR:
return "\"" + row.getString(index) + "\"";
case Types.DATE:
return "\"" + DATE_FORMAT_THREAD_LOCAL.get().format(row.getDate(index)) + "\"";
case Types.TIME:
return "\"" + TIME_FORMAT_THREAD_LOCAL.get().format(row.getDate(index)) + "\"";
case Types.TIMESTAMP:
return "\"" + DATE_TIME_FORMAT_THREAD_LOCAL.get().format(row.getDate(index)) + "\"";
default:
return row.getString(index);
}
}
}
示例5: isCharColumn
/**
* Determine if a column is char or a char-variant type.
* @return true if column type is CHAR, VARCHAR, LONGVARCHAR
* or their N version. These are used to store strings.
*/
public boolean isCharColumn(int columnType) {
return (columnType == Types.VARCHAR)
|| (columnType == Types.NVARCHAR)
|| (columnType == Types.CHAR)
|| (columnType == Types.NCHAR)
|| (columnType == Types.LONGVARCHAR)
|| (columnType == Types.LONGNVARCHAR);
}
示例6: columnClassNames
@DataProvider(name = "columnClassNames")
private Object[][] columnClassNames() {
return new Object[][]{
{Types.CHAR, "java.lang.String"},
{Types.NCHAR, "java.lang.String"},
{Types.VARCHAR, "java.lang.String"},
{Types.NVARCHAR, "java.lang.String"},
{Types.LONGVARCHAR, "java.lang.String"},
{Types.LONGNVARCHAR, "java.lang.String"},
{Types.NUMERIC, "java.math.BigDecimal"},
{Types.DECIMAL, "java.math.BigDecimal"},
{Types.BIT, "java.lang.Boolean"},
{Types.TINYINT, "java.lang.Byte"},
{Types.SMALLINT, "java.lang.Short"},
{Types.INTEGER, "java.lang.Integer"},
{Types.FLOAT, "java.lang.Double"},
{Types.DOUBLE, "java.lang.Double"},
{Types.BINARY, "byte[]"},
{Types.VARBINARY, "byte[]"},
{Types.LONGVARBINARY, "byte[]"},
{Types.DATE, "java.sql.Date"},
{Types.TIME, "java.sql.Time"},
{Types.TIMESTAMP, "java.sql.Timestamp"},
{Types.CLOB, "java.sql.Clob"},
{Types.BLOB, "java.sql.Blob"}
};
}
示例7: isNStringColumn
/**
* Says if a column is N Type
*
* @param columnType
* the SQL Column Type
* @return true if a column is N Type
*/
private boolean isNStringColumn(int columnType) {
if (columnType == Types.NCHAR || columnType == Types.NVARCHAR
|| columnType == Types.LONGNVARCHAR) {
return true;
} else {
return false;
}
}
示例8: getTypeClass
protected static Class<? extends Object> getTypeClass(DBColumn col) {
int colType = col.getJdbcType();
if (colType == Types.BIT && col.getPrecision() <= 1) {
colType = Types.BOOLEAN;
}
switch (colType) {
case Types.BOOLEAN:
return Boolean.class;
case Types.TIME:
return Time.class;
case Types.DATE:
return Date.class;
case Types.TIMESTAMP:
case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP:
case DBReadWriteHelper.SQL_TYPE_ORACLE_TIMESTAMP_WITH_TZ:
return Timestamp.class;
case Types.BIGINT:
return BigInteger.class;
case Types.DOUBLE:
return Double.class;
case Types.FLOAT:
case Types.REAL:
return Float.class;
case Types.DECIMAL:
case Types.NUMERIC:
return BigDecimal.class;
case Types.INTEGER:
case Types.SMALLINT:
case Types.TINYINT:
return Long.class;
case Types.CHAR:
case Types.VARCHAR:
case Types.NCHAR:
case Types.NVARCHAR:
case Types.ROWID:
return String.class;
case Types.BIT:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.BLOB:
return Blob.class;
case Types.LONGVARCHAR:
case Types.LONGNVARCHAR:
case Types.CLOB:
case Types.NCLOB: /*NCLOB */
return Clob.class;
case Types.OTHER:
default:
return Object.class;
}
}
示例9: isJdbcCharacterColumn
public boolean isJdbcCharacterColumn() {
return jdbcType == Types.CHAR || jdbcType == Types.CLOB
|| jdbcType == Types.LONGVARCHAR || jdbcType == Types.VARCHAR
|| jdbcType == Types.LONGNVARCHAR || jdbcType == Types.NCHAR
|| jdbcType == Types.NCLOB || jdbcType == Types.NVARCHAR;
}
示例10: toJavaType
/**
* Resolve a database-specific type to the Java type that should contain it.
* @param sqlType sql type
* @return the name of a Java type to hold the sql datatype, or null if none.
*/
public String toJavaType(int sqlType) {
// Mappings taken from:
// http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html
if (sqlType == Types.INTEGER) {
return "Integer";
} else if (sqlType == Types.VARCHAR) {
return "String";
} else if (sqlType == Types.CHAR) {
return "String";
} else if (sqlType == Types.LONGVARCHAR) {
return "String";
} else if (sqlType == Types.NVARCHAR) {
return "String";
} else if (sqlType == Types.NCHAR) {
return "String";
} else if (sqlType == Types.LONGNVARCHAR) {
return "String";
} else if (sqlType == Types.NUMERIC) {
return "java.math.BigDecimal";
} else if (sqlType == Types.DECIMAL) {
return "java.math.BigDecimal";
} else if (sqlType == Types.BIT) {
return "Boolean";
} else if (sqlType == Types.BOOLEAN) {
return "Boolean";
} else if (sqlType == Types.TINYINT) {
return "Integer";
} else if (sqlType == Types.SMALLINT) {
return "Integer";
} else if (sqlType == Types.BIGINT) {
return "Long";
} else if (sqlType == Types.REAL) {
return "Float";
} else if (sqlType == Types.FLOAT) {
return "Double";
} else if (sqlType == Types.DOUBLE) {
return "Double";
} else if (sqlType == Types.DATE) {
return "java.sql.Date";
} else if (sqlType == Types.TIME) {
return "java.sql.Time";
} else if (sqlType == Types.TIMESTAMP) {
return "java.sql.Timestamp";
// } else if (sqlType == Types.BINARY
// || sqlType == Types.VARBINARY) {
// return BytesWritable.class.getName();
// } else if (sqlType == Types.CLOB) {
// return ClobRef.class.getName();
// } else if (sqlType == Types.BLOB
// || sqlType == Types.LONGVARBINARY) {
// return BlobRef.class.getName();
} else {
// TODO(aaron): Support DISTINCT, ARRAY, STRUCT, REF, JAVA_OBJECT.
// Return null indicating database-specific manager should return a
// java data type if it can find one for any nonstandard type.
return null;
}
}
示例11: getSplitter
/**
* @return the DBSplitter implementation to use to divide the table/query
* into InputSplits.
*/
public DBSplitter getSplitter(int sqlDataType, long splitLimit, String rangeStyle) {
switch (sqlDataType) {
case Types.NUMERIC:
case Types.DECIMAL:
if(splitLimit >= 0) {
throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
}
return new BigDecimalSplitter();
case Types.BIT:
case Types.BOOLEAN:
if(splitLimit >= 0) {
throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
}
return new BooleanSplitter();
case Types.INTEGER:
case Types.TINYINT:
case Types.SMALLINT:
case Types.BIGINT:
return new IntegerSplitter();
case Types.REAL:
case Types.FLOAT:
case Types.DOUBLE:
if(splitLimit >= 0) {
throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
}
return new FloatSplitter();
case Types.NVARCHAR:
case Types.NCHAR:
if(splitLimit >= 0) {
throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
}
return new NTextSplitter(rangeStyle);
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
if(splitLimit >= 0) {
throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
}
return new TextSplitter(rangeStyle);
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return new DateSplitter();
default:
// TODO: Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, CLOB,
// BLOB, ARRAY, STRUCT, REF, DATALINK, and JAVA_OBJECT.
if(splitLimit >= 0) {
throw new IllegalArgumentException("split-limit is supported only with Integer and Date columns");
}
return null;
}
}
示例12: toJavaType
/**
* Resolve a database-specific type to the Java type that should contain it.
* @param sqlType sql type
* @return the name of a Java type to hold the sql datatype, or null if none.
*/
public String toJavaType(int sqlType) {
// Mappings taken from:
// http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/mapping.html
if (sqlType == Types.INTEGER) {
return "Integer";
} else if (sqlType == Types.VARCHAR) {
return "String";
} else if (sqlType == Types.CHAR) {
return "String";
} else if (sqlType == Types.LONGVARCHAR) {
return "String";
} else if (sqlType == Types.NVARCHAR) {
return "String";
} else if (sqlType == Types.NCHAR) {
return "String";
} else if (sqlType == Types.LONGNVARCHAR) {
return "String";
} else if (sqlType == Types.NUMERIC) {
return "java.math.BigDecimal";
} else if (sqlType == Types.DECIMAL) {
return "java.math.BigDecimal";
} else if (sqlType == Types.BIT) {
return "Boolean";
} else if (sqlType == Types.BOOLEAN) {
return "Boolean";
} else if (sqlType == Types.TINYINT) {
return "Integer";
} else if (sqlType == Types.SMALLINT) {
return "Integer";
} else if (sqlType == Types.BIGINT) {
return "Long";
} else if (sqlType == Types.REAL) {
return "Float";
} else if (sqlType == Types.FLOAT) {
return "Double";
} else if (sqlType == Types.DOUBLE) {
return "Double";
} else if (sqlType == Types.DATE) {
return "java.sql.Date";
} else if (sqlType == Types.TIME) {
return "java.sql.Time";
} else if (sqlType == Types.TIMESTAMP) {
return "java.sql.Timestamp";
} else if (sqlType == Types.BINARY
|| sqlType == Types.VARBINARY) {
return BytesWritable.class.getName();
} else if (sqlType == Types.CLOB) {
return ClobRef.class.getName();
} else if (sqlType == Types.BLOB
|| sqlType == Types.LONGVARBINARY) {
return BlobRef.class.getName();
} else {
// TODO(aaron): Support DISTINCT, ARRAY, STRUCT, REF, JAVA_OBJECT.
// Return null indicating database-specific manager should return a
// java data type if it can find one for any nonstandard type.
return null;
}
}
示例13: getParameterJavaValue
static public Object getParameterJavaValue(int param_type, String value) throws UnsupportedEncodingException, MalformedURLException, SQLException {
if (value != null) {
switch (param_type) {
case Types.ARRAY:
return value.split(",");
case Types.BIGINT:
return Long.valueOf(value);
case Types.BINARY:
return String.valueOf(value).getBytes("UTF-8");
case Types.BIT:
return Boolean.valueOf(value);
case Types.BLOB:
return value;//connection.createBlob();//
case Types.BOOLEAN:
return Boolean.valueOf(value);
case Types.CHAR:
return String.valueOf(value);
case Types.CLOB:
return value;//connection.createClob();//
case Types.DATALINK:
return new java.net.URL(value);
case Types.DATE:
return java.sql.Date.valueOf(value);
case Types.DECIMAL:
return java.math.BigDecimal.valueOf(Double.valueOf(value));
case Types.DISTINCT:
return value;//Object.class;
case Types.DOUBLE:
return Double.valueOf(value);
case Types.FLOAT:
return Double.valueOf(value);
case Types.INTEGER:
return Integer.valueOf(value, 10);
case Types.JAVA_OBJECT:
return value;//Object.class;
case Types.LONGVARBINARY:
return String.valueOf(value).getBytes("UTF-8");
case Types.LONGVARCHAR:
return String.valueOf(value);
case Types.NCLOB:
return value;//connection.createNClob();//
case Types.NULL:
return null;//Object.class;
case Types.NUMERIC:
return java.math.BigDecimal.valueOf(Double.parseDouble(value));
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
return String.valueOf(value);
case Types.OTHER:
return value;//Object.class;
case Types.REAL:
return Float.parseFloat(value);
case Types.REF:
return value;//java.sql.Ref.class;
case Types.ROWID:
return value;//java.sql.RowId.class;
case Types.SMALLINT:
return Short.valueOf(value);
case Types.STRUCT:
return value;//connection.createStruct(typeName, attributes);//
case Types.SQLXML:
return value;//connection.createSQLXML();//
case Types.TIME:
return java.sql.Time.valueOf(value);
case Types.TIMESTAMP:
return java.sql.Timestamp.valueOf(value);
case Types.TINYINT:
return Byte.valueOf(value);
case Types.VARBINARY:
return String.valueOf(value).getBytes("UTF-8");
case Types.VARCHAR:
return String.valueOf(value);
default:
return value;
}
}
return null;
}
示例14: convertValue
private Object convertValue() throws SQLException {
switch (componentType.id) {
case Types.BOOLEAN:
case Types.BIT:
return componentAccessor.getBoolean();
case Types.TINYINT:
return componentAccessor.getByte();
case Types.SMALLINT:
return componentAccessor.getShort();
case Types.INTEGER:
return componentAccessor.getInt();
case Types.BIGINT:
return componentAccessor.getLong();
case Types.FLOAT:
return componentAccessor.getFloat();
case Types.DOUBLE:
return componentAccessor.getDouble();
case Types.ARRAY:
return componentAccessor.getArray();
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.NCHAR:
case Types.LONGNVARCHAR:
return componentAccessor.getString();
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
return componentAccessor.getBytes();
case Types.DECIMAL:
return componentAccessor.getBigDecimal();
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
case Types.STRUCT:
case Types.JAVA_OBJECT:
return componentAccessor.getObject();
default:
throw new IllegalStateException("Unhandled ARRAY component type: " + componentType.rep
+ ", id: " + componentType.id);
}
}
示例15: sqlTypeString
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>";
}
}