本文整理汇总了Java中java.sql.Types.BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java Types.BOOLEAN属性的具体用法?Java Types.BOOLEAN怎么用?Java Types.BOOLEAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.BOOLEAN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractColumnType
public static int extractColumnType(Type type)
{
if (type.equals(Type.bool()))
return Types.BOOLEAN;
if (type.equals(Type.bytes()))
return Types.BINARY;
if (type.equals(Type.date()))
return Types.DATE;
if (type.equals(Type.float64()))
return Types.DOUBLE;
if (type.equals(Type.int64()))
return Types.BIGINT;
if (type.equals(Type.string()))
return Types.NVARCHAR;
if (type.equals(Type.timestamp()))
return Types.TIMESTAMP;
if (type.getCode() == Code.ARRAY)
return Types.ARRAY;
return Types.OTHER;
}
示例2: createIndexInfoFields
protected Field[] createIndexInfoFields() {
Field[] fields = new Field[13];
fields[0] = new Field("", "TABLE_CAT", Types.CHAR, 255);
fields[1] = new Field("", "TABLE_SCHEM", Types.CHAR, 0);
fields[2] = new Field("", "TABLE_NAME", Types.CHAR, 255);
fields[3] = new Field("", "NON_UNIQUE", Types.BOOLEAN, 4);
fields[4] = new Field("", "INDEX_QUALIFIER", Types.CHAR, 1);
fields[5] = new Field("", "INDEX_NAME", Types.CHAR, 32);
fields[6] = new Field("", "TYPE", Types.SMALLINT, 32);
fields[7] = new Field("", "ORDINAL_POSITION", Types.SMALLINT, 5);
fields[8] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
fields[9] = new Field("", "ASC_OR_DESC", Types.CHAR, 1);
if (Util.isJdbc42()) {
fields[10] = new Field("", "CARDINALITY", Types.BIGINT, 20);
fields[11] = new Field("", "PAGES", Types.BIGINT, 20);
} else {
fields[10] = new Field("", "CARDINALITY", Types.INTEGER, 20);
fields[11] = new Field("", "PAGES", Types.INTEGER, 10);
}
fields[12] = new Field("", "FILTER_CONDITION", Types.CHAR, 32);
return fields;
}
示例3: getColumnTypeName
@Override
public String getColumnTypeName(int column) throws SQLException {
// 数据库特定的类型名称
switch (keytype[column-1]){
case Types.INTEGER: return "INTEGER";
case Types.BOOLEAN: return "BOOLEAN";
case Types.BIT: return "BITT";
case Types.FLOAT: return "FLOAT";
case Types.BIGINT: return "BIGINT";
case Types.DOUBLE: return "DOUBLE";
case Types.DATE: return "DATE";
case Types.TIME: return "TIME";
case Types.TIMESTAMP: return "TIMESTAMP";
default: return "varchar";
}
}
示例4: 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;
}
}
示例5: getSplitter
/**
* @return the DBSplitter implementation to use to divide the table/query into InputSplits.
*/
protected DBSplitter getSplitter(int sqlDataType) {
switch (sqlDataType) {
case Types.NUMERIC:
case Types.DECIMAL:
return new BigDecimalSplitter();
case Types.BIT:
case Types.BOOLEAN:
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:
return new FloatSplitter();
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
return new TextSplitter();
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.
return null;
}
}
示例6: getSelectClauseNullString
@Override
public String getSelectClauseNullString(int sqlType) {
String literal;
switch ( sqlType ) {
case Types.LONGVARCHAR:
case Types.VARCHAR:
case Types.CHAR:
literal = "cast(null as varchar(100))";
break;
case Types.LONGVARBINARY:
case Types.VARBINARY:
case Types.BINARY:
literal = "cast(null as varbinary(100))";
break;
case Types.CLOB:
literal = "cast(null as clob)";
break;
case Types.BLOB:
literal = "cast(null as blob)";
break;
case Types.DATE:
literal = "cast(null as date)";
break;
case Types.TIMESTAMP:
literal = "cast(null as timestamp)";
break;
case Types.BOOLEAN:
literal = "cast(null as boolean)";
break;
case Types.BIT:
literal = "cast(null as bit)";
break;
case Types.TIME:
literal = "cast(null as time)";
break;
default:
literal = "cast(null as int)";
}
return literal;
}
示例7: getSqlTypeDescriptorOverride
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
return sqlCode == Types.BOOLEAN ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
示例8: getSQLType
int getSQLType()
{
return Types.BOOLEAN;
}
示例9: setParamValue
private void setParamValue(PreparedStatement ps, int psIdx, ResultSetRow row, int rsIdx, int sqlType) throws SQLException {
byte[] val = row.getColumnValue(rsIdx);
if (val == null) {
ps.setNull(psIdx, Types.NULL);
return;
}
switch (sqlType) {
case Types.NULL:
ps.setNull(psIdx, Types.NULL);
break;
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
ps.setInt(psIdx, row.getInt(rsIdx));
break;
case Types.BIGINT:
ps.setLong(psIdx, row.getLong(rsIdx));
break;
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.DECIMAL:
case Types.NUMERIC:
ps.setString(psIdx, row.getString(rsIdx, this.charEncoding, this.connection));
break;
case Types.DATE:
ps.setDate(psIdx, row.getDateFast(rsIdx, this.connection, this, this.fastDefaultCal), this.fastDefaultCal);
break;
case Types.TIMESTAMP:
ps.setTimestamp(psIdx, row.getTimestampFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this));
break;
case Types.TIME:
ps.setTime(psIdx, row.getTimeFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this));
break;
case Types.FLOAT:
case Types.DOUBLE:
case Types.REAL:
case Types.BOOLEAN:
ps.setBytesNoEscapeNoQuotes(psIdx, val);
break;
/*
* default, but also explicitly for following types:
* case Types.BINARY:
* case Types.BLOB:
*/
default:
ps.setBytes(psIdx, val);
break;
}
}
示例10: next
@Override
public boolean next() throws OdaException
{
if( currentRow >= maxRows )
{
return false;
}
try
{
if( resultSet.next() )
{
currentRow++;
for( int i = 1; i <= numCols; i++ )
{
int type = metaData.getColumnType(i);
Object obj;
switch( type )
{
case Types.TIMESTAMP:
obj = resultSet.getTimestamp(i);
break;
case Types.FLOAT:
case Types.REAL:
case Types.DOUBLE:
obj = resultSet.getDouble(i);
break;
case Types.INTEGER:
case Types.SMALLINT:
case Types.TINYINT:
obj = resultSet.getInt(i);
break;
case Types.BIGINT:
case Types.DECIMAL:
case Types.NUMERIC:
obj = resultSet.getBigDecimal(i);
break;
case Types.BOOLEAN:
case Types.BIT:
obj = resultSet.getBoolean(i) ? 1 : 0;
break;
default:
obj = resultSet.getString(i);
break;
}
rowData[i - 1] = obj;
}
return true;
}
return false;
}
catch( SQLException sqle )
{
throw new OdaException(sqle);
}
}
示例11: 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;
}
}
示例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: getSplitter
/**
* @return the DBSplitter implementation to use to divide the table/query
* into InputSplits.
*/
protected DBSplitter getSplitter(int sqlDataType, long splitLimit) {
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();
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();
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;
}
}
示例14: getSqlTypeDescriptorOverride
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
return sqlCode == Types.BOOLEAN ? BitTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
示例15: columnTypeIsBoolean
private boolean columnTypeIsBoolean(int columnType) {
return columnType == Types.BOOLEAN || columnType == Types.BIT;
}