本文整理汇总了Java中java.sql.Types.NULL属性的典型用法代码示例。如果您正苦于以下问题:Java Types.NULL属性的具体用法?Java Types.NULL怎么用?Java Types.NULL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.NULL属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearParameters
/**
* In general, parameter values remain in force for repeated used of a
* Statement. Setting a parameter value automatically clears its previous
* value. However, in some cases, it is useful to immediately release the
* resources used by the current parameter values; this can be done by
* calling clearParameters
*
* @exception SQLException
* if a database access error occurs
*/
public void clearParameters() throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
for (int i = 0; i < this.parameterValues.length; i++) {
this.parameterValues[i] = null;
this.parameterStreams[i] = null;
this.isStream[i] = false;
this.isNull[i] = false;
this.parameterTypes[i] = Types.NULL;
}
}
}
示例2: build
@Override
public Argument build(Class<?> expectedType, Value<?> value, StatementContext ctx) {
if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(jdbcDriver)) {
return new MsSqlValueArgument(value);
} else if ("oracle.jdbc.OracleDriver".equals(jdbcDriver)) {
return new DefaultValueArgument(value, Types.NULL);
}
return new DefaultValueArgument(value);
}
示例3: setSqlType
public void setSqlType(String sqlType) {
try {
this.sqlType = Integer.parseInt(sqlType);
} catch (Exception e) { // ignore error
this.sqlType = Types.NULL;
}
}
示例4: 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;
}
}
示例5: 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
}
}
示例6: Memory
/** Default constructor.
*/
Memory () {
super();
_type = Types.NULL;
}
示例7: 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;
}
}
示例8: 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>";
}
}
示例9: fillWindow
@Override
public void fillWindow(int position, CursorWindow window) {
if (position < 0 || position > getCount()) {
return;
}
window.acquireReference();
try {
int oldpos = getPosition();
moveToPosition(position - 1);
window.clear();
window.setStartPosition(position);
int columnNum = getColumnCount();
window.setNumColumns(columnNum);
while (moveToNext() && window.allocRow()) {
int pos = getPosition();
for (int i = 0; i < columnNum; i++) {
boolean hasRoom = true;
switch (getColumnType(i)) {
case Types.DOUBLE:
hasRoom = fillRow(window, Double.valueOf(getDouble(i)), pos, i);
break;
case Types.NUMERIC:
hasRoom = fillRow(window, Long.valueOf(getLong(i)), pos, i);
break;
case Types.BLOB:
hasRoom = fillRow(window, getBlob(i), pos, i);
break;
case Types.LONGVARCHAR:
hasRoom = fillRow(window, getString(i), pos, i);
break;
case Types.NULL:
hasRoom = fillRow(window, null, pos, i);
break;
default:
// Ignore an unknown type.
}
if (!hasRoom) {
break;
}
}
}
moveToPosition(oldpos);
} catch (IllegalStateException e) {
// simply ignore it
} finally {
window.releaseReference();
}
}
示例10: 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;
}
示例11: getParameterJavaClass
static public Class<?> getParameterJavaClass(int param_type) {
switch (param_type) {
case Types.ARRAY:
return Object[].class;
case Types.BIGINT:
return Long.class;
case Types.BINARY:
return byte[].class;
case Types.BIT:
return Boolean.class;
case Types.BLOB:
return java.sql.Blob.class;
case Types.BOOLEAN:
return Boolean.class;
case Types.CHAR:
return String.class;
case Types.CLOB:
return java.sql.Clob.class;
case Types.DATALINK:
return java.net.URL.class;
case Types.DATE:
return java.sql.Date.class;
case Types.DECIMAL:
return java.math.BigDecimal.class;
case Types.DISTINCT:
return Object.class;
case Types.DOUBLE:
return Double.class;
case Types.FLOAT:
return Double.class;
case Types.INTEGER:
return Integer.class;
case Types.JAVA_OBJECT:
return Object.class;
case Types.LONGVARBINARY:
return byte[].class;
case Types.LONGVARCHAR:
return String.class;
case Types.NCLOB:
return java.sql.NClob.class;
case Types.NULL:
return Object.class;
case Types.NUMERIC:
return java.math.BigDecimal.class;
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
return String.class;
case Types.OTHER:
return Object.class;
case Types.REAL:
return Float.class;
case Types.REF:
return java.sql.Ref.class;
case Types.ROWID:
return java.sql.RowId.class;
case Types.SMALLINT:
return Short.class;
case Types.STRUCT:
return java.sql.Struct.class;
case Types.SQLXML:
return java.sql.SQLXML.class;
case Types.TIME:
return java.sql.Time.class;
case Types.TIMESTAMP:
return java.sql.Timestamp.class;
case Types.TINYINT:
return Byte.class;
case Types.VARBINARY:
return byte[].class;
case Types.VARCHAR:
return String.class;
default:
return Object.class;
}
}
示例12: getSelectClauseNullString
@Override
public String getSelectClauseNullString(int sqlType) {
String v = "null";
switch ( sqlType ) {
case Types.BIT:
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
case Types.BIGINT:
case Types.FLOAT:
case Types.REAL:
case Types.DOUBLE:
case Types.NUMERIC:
case Types.DECIMAL:
v = "cast(null as decimal)";
break;
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
v = "cast(null as varchar(255))";
break;
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
v = "cast(null as timestamp)";
break;
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
case Types.NULL:
case Types.OTHER:
case Types.JAVA_OBJECT:
case Types.DISTINCT:
case Types.STRUCT:
case Types.ARRAY:
case Types.BLOB:
case Types.CLOB:
case Types.REF:
case Types.DATALINK:
case Types.BOOLEAN:
break;
default:
break;
}
return v;
}
示例13: classToJdbcType
/**
* Get the SQL type which corresponds to given Java type.
* @param type Java type
* @return SQL type
*/
public static int classToJdbcType(Class<?> type) {
if (type == null) {
return Types.NULL;
}
if (String.class.isAssignableFrom(type)) {
return Types.VARCHAR;
}
if (TypeUtils.isBoolean(type)) {
return Types.BOOLEAN;
}
if (TypeUtils.isInteger(type)) {
return Types.INTEGER;
}
if (TypeUtils.isLong(type)) {
return Types.BIGINT;
}
if (TypeUtils.isDouble(type) || TypeUtils.isFloat(type) || TypeUtils.isBigDecimal(type)) {
return Types.DECIMAL;
}
if (TypeUtils.isShort(type)) {
return Types.SMALLINT;
}
if (TypeUtils.isByte(type)) {
return Types.TINYINT;
}
if (TypeUtils.isNumber(type)) {
return Types.NUMERIC;
}
if (type == byte[].class) {
return Types.BINARY;
}
if (TypeUtils.isDate(type) || TypeUtils.isCalendar(type) || java.sql.Date.class.isAssignableFrom(type)
|| LocalDate.class.isAssignableFrom(type)) {
return Types.DATE;
}
if (LocalTime.class.isAssignableFrom(type) || java.sql.Time.class.isAssignableFrom(type)) {
return Types.TIME;
}
if (LocalDateTime.class.isAssignableFrom(type) || java.sql.Timestamp.class.isAssignableFrom(type)) {
return Types.TIMESTAMP;
}
if (ZonedDateTime.class.isAssignableFrom(type)) {
return Types.TIMESTAMP_WITH_TIMEZONE;
}
return Types.OTHER;
}
示例14: setNull
/**
* Set a parameter to SQL NULL
*
* <p>
* <B>Note:</B> You must specify the parameters SQL type (although MySQL ignores it)
* </p>
*
* @param parameterIndex
* the first parameter is 1, etc...
* @param sqlType
* the SQL type code defined in java.sql.Types
*
* @exception SQLException
* if a database access error occurs
*/
public void setNull(int parameterIndex, int sqlType) throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
setInternal(parameterIndex, "null");
this.isNull[parameterIndex - 1 + getParameterIndexOffset()] = true;
this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.NULL;
}
}