本文整理汇总了Java中java.sql.Types.NCLOB属性的典型用法代码示例。如果您正苦于以下问题:Java Types.NCLOB属性的具体用法?Java Types.NCLOB怎么用?Java Types.NCLOB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.NCLOB属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isClobColumn
/**
* return true if the column is a Types.CLOB || Types.NCLOB
*
* @param columnType
* the sql column type
* @return true if it's (N)CLOB
*/
private boolean isClobColumn(int columnType) {
// 18/11/11 23:20 NDP : ResultSetWriter: no file dump for
// ResultSetMetaData queries
if (sqlOrder.equals("ResultSetMetaData")) {
return false;
}
if (columnType == Types.CLOB || columnType == Types.LONGVARCHAR
|| columnType == Types.NCLOB) {
return true;
} else {
return false;
}
}
示例2: getSqlTypeDescriptorOverride
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) {
switch ( sqlCode ) {
case Types.BOOLEAN:
return BitTypeDescriptor.INSTANCE;
case Types.CLOB:
return HANA_CLOB_STREAM_BINDING;
case Types.NCLOB:
return HANA_NCLOB_STREAM_BINDING;
case Types.TINYINT:
// tinyint is unsigned on HANA
return SmallIntTypeDescriptor.INSTANCE;
default:
return super.getSqlTypeDescriptorOverride( sqlCode );
}
}
示例3: isBlob
/**
* Return if a given data type is blob type or not. Note: CLOB should really
* not be in this list, use isLob method for that.
*
* @param type the type from java.sql.Types return true if the give type is
* blob type; false otherwise
*/
static public boolean isBlob(int type) {
switch (type) {
case Types.BLOB:
case Types.CLOB:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.OTHER:
case Types.NCLOB:
return true;
}
return false;
}
示例4: encoding
public static String encoding(String source, int sqlType, String sourceEncoding, String targetEncoding) {
switch (sqlType) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
case Types.CLOB:
case Types.NCLOB:
if (false == StringUtils.isEmpty(source)) {
String fromEncoding = StringUtils.isBlank(sourceEncoding) ? "UTF-8" : sourceEncoding;
String toEncoding = StringUtils.isBlank(targetEncoding) ? "UTF-8" : targetEncoding;
// if (false == StringUtils.equalsIgnoreCase(fromEncoding,
// toEncoding)) {
try {
return new String(source.getBytes(fromEncoding), toEncoding);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
// }
}
}
return source;
}
示例5: 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;
}
}
示例6: buildWithCallback
@SuppressWarnings("unchecked")
public static final void buildWithCallback(AbstractConfig config, ResultSet rs, final Callback callback) throws SQLException {
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
String[] labelNames = new String[columnCount + 1];
int[] types = new int[columnCount + 1];
buildLabelNamesAndTypes(rsmd, labelNames, types);
while (rs.next()) {
Record record = new Record();
record.setColumnsMap(config.containerFactory.getColumnsMap());
Map<String, Object> columns = record.getColumns();
for (int i=1; i<=columnCount; i++) {
Object value;
if (types[i] < Types.BLOB)
value = rs.getObject(i);
else if (types[i] == Types.CLOB)
value = ModelBuilder.handleClob(rs.getClob(i));
else if (types[i] == Types.NCLOB)
value = ModelBuilder.handleClob(rs.getNClob(i));
else if (types[i] == Types.BLOB)
value = ModelBuilder.handleBlob(rs.getBlob(i));
else
value = rs.getObject(i);
columns.put(labelNames[i], value);
}
int rowIndex = rs.getRow();
if (callback != null) {
callback.invoke(record, rowIndex);
}
}
}
示例7: buildRecord
private List<Record> buildRecord(ResultSet rs, int pageSize) throws SQLException {
List<Record> result = new ArrayList<Record>();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
String[] labelNames = new String[columnCount + 1];
int[] types = new int[columnCount + 1];
buildLabelNamesAndTypes(rsmd, labelNames, types);
for (int k=0; k<pageSize && rs.next(); k++) {
Record record = new Record();
Map<String, Object> columns = record.getColumns();
for (int i=1; i<=columnCount; i++) {
Object value;
if (types[i] < Types.BLOB)
value = rs.getObject(i);
else if (types[i] == Types.CLOB)
value = ModelBuilder.handleClob(rs.getClob(i));
else if (types[i] == Types.NCLOB)
value = ModelBuilder.handleClob(rs.getNClob(i));
else if (types[i] == Types.BLOB)
value = ModelBuilder.handleBlob(rs.getBlob(i));
else
value = rs.getObject(i);
columns.put(labelNames[i], value);
}
result.add(record);
}
return result;
}
示例8: buildModel
@SuppressWarnings({"rawtypes", "unchecked"})
public final <T> List<T> buildModel(ResultSet rs, Class<? extends Model> modelClass, int pageSize) throws SQLException, InstantiationException, IllegalAccessException {
List<T> result = new ArrayList<T>();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
String[] labelNames = new String[columnCount + 1];
int[] types = new int[columnCount + 1];
buildLabelNamesAndTypes(rsmd, labelNames, types);
for (int k=0; k<pageSize && rs.next(); k++) {
Model<?> ar = modelClass.newInstance();
Map<String, Object> attrs = CPI.getAttrs(ar);
for (int i=1; i<=columnCount; i++) {
Object value;
if (types[i] < Types.BLOB)
value = rs.getObject(i);
else if (types[i] == Types.CLOB)
value = ModelBuilder.handleClob(rs.getClob(i));
else if (types[i] == Types.NCLOB)
value = ModelBuilder.handleClob(rs.getNClob(i));
else if (types[i] == Types.BLOB)
value = ModelBuilder.handleBlob(rs.getBlob(i));
else
value = rs.getObject(i);
attrs.put(labelNames[i], value);
}
result.add((T)ar);
}
return result;
}
示例9: getSQLType
/**
* 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;
}
}
示例10: 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;
}
}
示例11: getSqlTypeString
/**
* Convert sql types to String for display
*
* @param sqlType the type number from java.sql.Types
* @return the type name
*/
static public String getSqlTypeString(int sqlType) {
switch (sqlType) {
case Types.BIGINT:
return "BIGINT"; //NOI18N
case Types.BINARY:
return "BINARY"; //NOI18N
case Types.BIT:
return "BIT"; //NOI18N
case Types.NCHAR:
return "NCHAR"; //NOI18N
case Types.CHAR:
return "CHAR"; //NOI18N
case Types.DATE:
return "DATE"; //NOI18N
case Types.DECIMAL:
return "DECIMAL"; //NOI18N
case Types.DOUBLE:
return "DOUBLE"; //NOI18N
case Types.FLOAT:
return "FLOAT"; //NOI18N
case Types.INTEGER:
return "INTEGER"; //NOI18N
case Types.LONGVARBINARY:
return "LONGVARBINARY"; //NOI18N
case Types.LONGNVARCHAR:
return "LONGNVARCHAR"; //NOI18N
case Types.LONGVARCHAR:
return "LONGVARCHAR"; //NOI18N
case Types.NULL:
return "NULL"; //NOI18N
case Types.NUMERIC:
return "NUMERIC"; //NOI18N
case Types.OTHER:
return "OTHER"; //NOI18N
case Types.REAL:
return "REAL"; //NOI18N
case Types.SMALLINT:
return "SMALLINT"; //NOI18N
case Types.TIME:
return "TIME"; //NOI18N
case Types.TIMESTAMP:
return "TIMESTAMP"; //NOI18N
case Types.TINYINT:
return "TINYINT"; //NOI18N
case Types.VARBINARY:
return "VARBINARY"; //NOI18N
case Types.NVARCHAR:
return "NVARCHAR";
case Types.VARCHAR:
return "VARCHAR"; //NOI18N
case Types.JAVA_OBJECT:
return "JAVA_OBJECT"; //NOI18N
case Types.DISTINCT:
return "DISTINCT"; //NOI18N
case Types.STRUCT:
return "STRUCT"; //NOI18N
case Types.ARRAY:
return "ARRAY"; //NOI18N
case Types.BLOB:
return "BLOB"; //NOI18N
case Types.NCLOB:
return "NCLOB";
case Types.CLOB:
return "CLOB"; //NOI18N
case Types.REF:
return "REF"; //NOI18N
default:
Logger.getLogger(SQLTypeUtil.class.getName()).log(Level.WARNING, "Unknown JDBC column type: {0}. Returns null.", sqlType);
return "UNKNOWN"; //NOI18N
}
}
示例12: 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;
}
示例13: isLOB
public boolean isLOB() {
return jdbcType == Types.BLOB || jdbcType == Types.CLOB || jdbcType == Types.NCLOB ||
name.endsWith("CLOB") || "BLOB".equals(name);
}
示例14: dataTypeFromSqlType
/**
* Converts a given SQL data type to a {@link DataType}.
*
* @param sqlType The jdbc data type to convert.
* @param typeName The (potentially database specific) type name
* @param width The width of the column
* @return The Cryo DataType that represents the sql connection data type
* given in <var>sqlType</var>.
*/
protected DataType dataTypeFromSqlType(int sqlType, String typeName, @SuppressWarnings("unused") int width) {
switch (sqlType) {
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.BINARY:
return DataType.BOOLEAN;
case Types.DATE:
return DataType.DATE;
case Types.BLOB:
case Types.VARBINARY:
case Types.LONGVARBINARY:
return DataType.BLOB;
case Types.NCLOB:
case Types.CLOB:
return DataType.CLOB;
default:
throw new IllegalArgumentException("Unknown SQL data type [" + typeName + "] (" + sqlType + ")");
}
}
示例15: javaTypeMysql
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;
}
}