本文整理汇总了Java中java.sql.Types.BIT属性的典型用法代码示例。如果您正苦于以下问题:Java Types.BIT属性的具体用法?Java Types.BIT怎么用?Java Types.BIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.BIT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineNeedsQuoting
private boolean determineNeedsQuoting() {
boolean retVal = false;
switch (this.sqlType) {
case Types.BIGINT:
case Types.BIT:
case Types.DECIMAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.INTEGER:
case Types.NUMERIC:
case Types.REAL:
case Types.SMALLINT:
case Types.TINYINT:
retVal = false;
break;
default:
retVal = true;
}
return retVal;
}
示例2: overrideDefaultType
protected FullyQualifiedJavaType overrideDefaultType(IntrospectedColumn column, FullyQualifiedJavaType defaultType) {
FullyQualifiedJavaType answer = defaultType;
switch (column.getJdbcType()) {
case Types.BIT:
answer = calculateBitReplacement(column, defaultType);
break;
case Types.DECIMAL:
case Types.NUMERIC:
answer = calculateBigDecimalReplacement(column, defaultType);
break;
}
return answer;
}
示例3: isCaseSensitive
/**
* Does a column's case matter?
*
* @param column
* the first column is 1, the second is 2...
*
* @return true if so
*
* @throws java.sql.SQLException
* if a database access error occurs
*/
public boolean isCaseSensitive(int column) throws java.sql.SQLException {
Field field = getField(column);
int sqlType = field.getSQLType();
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.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return false;
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
if (field.isBinary()) {
return true;
}
String collationName = field.getCollation();
return ((collationName != null) && !collationName.endsWith("_ci"));
default:
return true;
}
}
示例4: 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"}
};
}
示例5: getNativeBinaryStream
/**
* A column value can also be retrieved as a binary stream. This method is
* suitable for retrieving LONGVARBINARY values.
*
* @param columnIndex
* the first column is 1, the second is 2...
*
* @return a Java InputStream that delivers the database column value as a
* stream of bytes. If the value is SQL NULL, then the result is
* null
*
* @exception SQLException
* if a database access error occurs
*
* @see getAsciiStream
* @see getUnicodeStream
*/
protected InputStream getNativeBinaryStream(int columnIndex) throws SQLException {
checkRowPos();
int columnIndexMinusOne = columnIndex - 1;
if (this.thisRow.isNull(columnIndexMinusOne)) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
switch (this.fields[columnIndexMinusOne].getSQLType()) {
case Types.BIT:
case Types.BINARY:
case Types.VARBINARY:
case Types.BLOB:
case Types.LONGVARBINARY:
return this.thisRow.getBinaryInputStream(columnIndexMinusOne);
}
byte[] b = getNativeBytes(columnIndex, false);
if (b != null) {
return new ByteArrayInputStream(b);
}
return null;
}
示例6: dbRepresentation
public String dbRepresentation(int column, Object value) {
int type;
if (value == null) {
return "null";
}
try {
type = metaData.getColumnType(column + 1);
} catch (SQLException e) {
return value.toString();
}
switch (type) {
case Types.INTEGER:
case Types.DOUBLE:
case Types.FLOAT:
return value.toString();
case Types.BIT:
return ((Boolean) value).booleanValue() ? "1" : "0";
case Types.DATE:
return value.toString(); // This will need some conversion.
default:
return "\"" + value.toString() + "\"";
}
}
示例7: 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;
}
示例8: getObjectToType
public static int getObjectToType(Object ob){
if (ob instanceof Integer) {
return Types.INTEGER;
}
else if (ob instanceof Boolean) {
return Types.BOOLEAN;
}
else if (ob instanceof Byte) {
return Types.BIT;
}
else if (ob instanceof Short) {
return Types.INTEGER;
}
else if (ob instanceof Float) {
return Types.FLOAT;
}
else if (ob instanceof Long) {
return Types.BIGINT;
}
else if (ob instanceof Double) {
return Types.DOUBLE;
}
else if (ob instanceof Date) {
return Types.DATE;
}
else if (ob instanceof Time) {
return Types.TIME;
}
else if (ob instanceof Timestamp) {
return Types.TIMESTAMP;
}
else if (ob instanceof String) {
return Types.VARCHAR;
}
else {
return Types.VARCHAR;
}
}
示例9: fromJavaToSql
public static String fromJavaToSql(int javaType) {
String sqlType = null;
if (javaType == Types.CHAR) {
sqlType = AceQLTypes.CHAR;
} else if (javaType == Types.VARCHAR) {
sqlType = AceQLTypes.VARCHAR;
} else if (javaType == Types.LONGVARCHAR) {
sqlType = AceQLTypes.LONGVARCHAR;
} else if (javaType == Types.NUMERIC) {
sqlType = AceQLTypes.NUMERIC;
} else if (javaType == Types.BIT) {
sqlType = AceQLTypes.BIT;
} else if (javaType == Types.NUMERIC) {
sqlType = AceQLTypes.NUMERIC;
} else if (javaType == Types.DECIMAL) {
sqlType = AceQLTypes.DECIMAL;
} else if (javaType == Types.TINYINT) {
sqlType = AceQLTypes.TINYINT;
} else if (javaType == Types.SMALLINT) {
sqlType = AceQLTypes.SMALLINT;
} else if (javaType == Types.INTEGER) {
sqlType = AceQLTypes.INTEGER;
} else if (javaType == Types.BIGINT) {
sqlType = AceQLTypes.BIGINT;
} else if (javaType == Types.REAL) {
sqlType = AceQLTypes.REAL;
} else if (javaType == Types.FLOAT) {
sqlType = AceQLTypes.FLOAT;
} else if (javaType == Types.DOUBLE) {
sqlType = AceQLTypes.DOUBLE_PRECISION;
} else if (javaType == Types.DATE) {
sqlType = AceQLTypes.DATE;
} else if (javaType == Types.TIME) {
sqlType = AceQLTypes.TIME;
} else if (javaType == Types.TIMESTAMP) {
sqlType = AceQLTypes.TIMESTAMP;
} else if (javaType == Types.BINARY) {
sqlType = AceQLTypes.BINARY;
} else if (javaType == Types.VARBINARY) {
sqlType = AceQLTypes.VARBINARY;
} else if (javaType == Types.LONGVARBINARY) {
sqlType = AceQLTypes.LONGVARBINARY;
} else if (javaType == Types.BLOB) {
sqlType = AceQLTypes.BLOB;
}
else if (javaType == Types.CLOB) {
sqlType = AceQLTypes.CLOB;
} else {
return "UNKNOWN";
}
return sqlType;
}
示例10: getClassForNumericType
private Class getClassForNumericType(Integer precision,
Integer scale, boolean isNullable) {
int precValue = ((precision == null) ? -1 : precision.intValue());
int scaleValue = ((scale == null) ? -1 : scale.intValue());
switch (sqlType) {
case Types.DECIMAL:
case Types.NUMERIC:
// some jdbc drivers put in null or zero for a numeric
// specified without precision or scale
// return BigInteger in that case
if ((precValue <= 0) && (scaleValue <= 0)){
return BigInteger.class;
}
if (scaleValue > 0) {
return BigDecimal.class;
}
if (precValue > 18) {
return BigInteger.class;
}
if (precValue > 9) {
return (isNullable ? Long.class : Long.TYPE);
}
if (precValue > 4) {
return (isNullable ? Integer.class : Integer.TYPE);
}
return (isNullable ? Short.class : Short.TYPE);
case Types.FLOAT:
case Types.DOUBLE:
case Types.REAL:
case Types.BIGINT:
case Types.INTEGER:
case Types.SMALLINT:
case Types.TINYINT:
case Types.BIT:
return typeList[isNullable ? 0 : 1];
default:
return null;
}
}
示例11: 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);
}
}
示例12: getSqlType
public int getSqlType() {
return Types.BIT;
}
示例13: toHCatType
/**
* Resolve a database-specific type to HCat data type. Largely follows Sqoop's
* hive translation.
* @param sqlType
* sql type
* @return hcat type
*/
public static String toHCatType(int sqlType) {
switch (sqlType) {
// Ideally TINYINT and SMALLINT should be mapped to their
// HCat equivalents tinyint and smallint respectively
// But the Sqoop Java type conversion has them mapped to Integer
// Even though the referenced Java doc clearly recommends otherwise.
// Changing this now can cause many of the sequence file usages to
// break as value class implementations will change. So, we
// just use the same behavior here.
case Types.SMALLINT:
case Types.TINYINT:
case Types.INTEGER:
return "int";
case Types.VARCHAR:
return "varchar";
case Types.CHAR:
return "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.FLOAT:
case Types.REAL:
return "float";
case Types.NUMERIC:
case Types.DECIMAL:
return "decimal";
case Types.DOUBLE:
return "double";
case Types.BIT:
case Types.BOOLEAN:
return "boolean";
case Types.BIGINT:
return "bigint";
case Types.BINARY:
case Types.VARBINARY:
case Types.BLOB:
case Types.LONGVARBINARY:
return "binary";
default:
throw new IllegalArgumentException(
"Cannot convert SQL type to HCatalog type " + sqlType);
}
}
示例14: setInOutParamsOnServer
private void setInOutParamsOnServer() throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
if (this.paramInfo.numParameters > 0) {
for (Iterator<CallableStatementParam> paramIter = this.paramInfo.iterator(); paramIter.hasNext();) {
CallableStatementParam inParamInfo = paramIter.next();
//Fix for 5.5+
if (inParamInfo.isOut && inParamInfo.isIn) {
if ((inParamInfo.paramName == null) && (hasParametersView())) {
inParamInfo.paramName = "nullnp" + inParamInfo.index;
}
String inOutParameterName = mangleParameterName(inParamInfo.paramName);
StringBuilder queryBuf = new StringBuilder(4 + inOutParameterName.length() + 1 + 1);
queryBuf.append("SET ");
queryBuf.append(inOutParameterName);
queryBuf.append("=?");
PreparedStatement setPstmt = null;
try {
setPstmt = ((Wrapper) this.connection.clientPrepareStatement(queryBuf.toString())).unwrap(PreparedStatement.class);
if (this.isNull[inParamInfo.index]) {
setPstmt.setBytesNoEscapeNoQuotes(1, "NULL".getBytes());
} else {
byte[] parameterAsBytes = getBytesRepresentation(inParamInfo.index);
if (parameterAsBytes != null) {
if (parameterAsBytes.length > 8 && parameterAsBytes[0] == '_' && parameterAsBytes[1] == 'b' && parameterAsBytes[2] == 'i'
&& parameterAsBytes[3] == 'n' && parameterAsBytes[4] == 'a' && parameterAsBytes[5] == 'r'
&& parameterAsBytes[6] == 'y' && parameterAsBytes[7] == '\'') {
setPstmt.setBytesNoEscapeNoQuotes(1, parameterAsBytes);
} else {
int sqlType = inParamInfo.desiredJdbcType;
switch (sqlType) {
case Types.BIT:
case Types.BINARY:
case Types.BLOB:
case Types.JAVA_OBJECT:
case Types.LONGVARBINARY:
case Types.VARBINARY:
setPstmt.setBytes(1, parameterAsBytes);
break;
default:
// the inherited PreparedStatement methods have already escaped and quoted these parameters
setPstmt.setBytesNoEscape(1, parameterAsBytes);
}
}
} else {
setPstmt.setNull(1, Types.NULL);
}
}
setPstmt.executeUpdate();
} finally {
if (setPstmt != null) {
setPstmt.close();
}
}
}
}
}
}
}
示例15: 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 + ")");
}
}