本文整理汇总了Java中java.sql.Types.TINYINT属性的典型用法代码示例。如果您正苦于以下问题:Java Types.TINYINT属性的具体用法?Java Types.TINYINT怎么用?Java Types.TINYINT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.TINYINT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertColumnValue
Object convertColumnValue(Object value, int column, int type) {
// solves a problem for MS SQL 7
if ((type == Types.SMALLINT) && (value instanceof Integer)) {
if (firstSmallintRow) {
firstSmallintRow = false;
tracer.trace("SMALLINT: Converted column " + column
+ " Integer to Short");
}
value = new Short((short) ((Integer) value).intValue());
} else if ((type == Types.TINYINT) && (value instanceof Integer)) {
if (firstTinyintRow) {
firstTinyintRow = false;
tracer.trace("TINYINT: Converted column " + column
+ " Integer to Byte");
}
value = new Byte((byte) ((Integer) value).intValue());
}
return (value);
}
示例2: getObject
public Object getObject(int parameterIndex) throws SQLException {
checkBounds(parameterIndex, 0);
if (this.parameterIsNull[parameterIndex - 1]) {
return null;
}
// we can't rely on the default mapping for JDBC's ResultSet.getObject() for numerics, they're not one-to-one with PreparedStatement.setObject
switch (PreparedStatement.this.parameterTypes[parameterIndex - 1]) {
case Types.TINYINT:
return Byte.valueOf(getByte(parameterIndex));
case Types.SMALLINT:
return Short.valueOf(getShort(parameterIndex));
case Types.INTEGER:
return Integer.valueOf(getInt(parameterIndex));
case Types.BIGINT:
return Long.valueOf(getLong(parameterIndex));
case Types.FLOAT:
return Float.valueOf(getFloat(parameterIndex));
case Types.DOUBLE:
return Double.valueOf(getDouble(parameterIndex));
default:
return this.bindingsAsRs.getObject(parameterIndex);
}
}
示例3: 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;
}
示例4: isNumeric
/**
* Returns if the given data type is numeric type or not.
*
* @param type the type from java.sql.Types
* @return true if the given type is numeric type; false otherwise
*/
static public boolean isNumeric(int type) {
switch (type) {
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:
return true;
}
return false;
}
示例5: isSigned
/**
* Is the column a signed number?
*
* @param column
* the first column is 1, the second is 2...
*
* @return true if so
*
* @throws SQLException
* if a database access error occurs
*/
public boolean isSigned(int column) throws SQLException {
Field f = getField(column);
int sqlType = f.getSQLType();
switch (sqlType) {
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:
return !f.isUnsigned();
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return false;
default:
return false;
}
}
示例6: isDecimalType
/**
* Checks if the SQL Type is a Decimal/Number Type
*
* @param type
* SQL Type
*/
private static final boolean isDecimalType(int type) {
switch (type) {
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:
return true;
}
return false;
}
示例7: getColumnClass
@Override
public Class<?> getColumnClass(int column) {
int type;
try {
type = metaData.getColumnType(column + 1);
} catch (SQLException e) {
return super.getColumnClass(column);
}
switch (type) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
return String.class;
case Types.BIT:
return Boolean.class;
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
return Integer.class;
case Types.BIGINT:
return Long.class;
case Types.FLOAT:
case Types.DOUBLE:
return Double.class;
case Types.DATE:
return java.sql.Date.class;
default:
return Object.class;
}
}
示例8: testBug25894
public void testBug25894() throws Exception {
createTable("bug25894",
"(tinyInt_type TINYINT DEFAULT 1, tinyIntU_type TINYINT UNSIGNED DEFAULT 1, smallInt_type SMALLINT DEFAULT 1,"
+ "smallIntU_type SMALLINT UNSIGNED DEFAULT 1, mediumInt_type MEDIUMINT DEFAULT 1, mediumIntU_type MEDIUMINT UNSIGNED DEFAULT 1,"
+ "int_type INT DEFAULT 1, intU_type INT UNSIGNED DEFAULT 1, bigInt_type BIGINT DEFAULT 1, bigIntU_type BIGINT UNSIGNED DEFAULT 1);");
this.stmt.executeUpdate("INSERT INTO bug25894 VALUES (-1,1,-1,1,-1,1,-1,1,-1,1)");
this.rs = this.stmt.executeQuery("SELECT * FROM bug25894");
java.sql.ResultSetMetaData tblMD = this.rs.getMetaData();
this.rs.first();
for (int i = 1; i < tblMD.getColumnCount() + 1; i++) {
String typesName = "";
switch (tblMD.getColumnType(i)) {
case Types.INTEGER:
typesName = "Types.INTEGER";
break;
case Types.TINYINT:
typesName = "Types.TINYINT";
break;
case Types.BIGINT:
typesName = "Types.BIGINT";
break;
case Types.SMALLINT:
typesName = "Types.SMALLINT";
break;
}
System.out.println(i + " .fld: " + tblMD.getColumnName(i) + "T: " + typesName + ", MDC: " + tblMD.getColumnClassName(i) + " "
+ tblMD.getColumnTypeName(i) + " , getObj: " + this.rs.getObject(i).getClass());
}
}
示例9: setObject
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
{
checkParameterBounds(parameterIndex);
switch(targetSqlType)
{
case Types.TINYINT:
setByte(parameterIndex, ((Byte)x).byteValue());
break;
case Types.SMALLINT:
setShort(parameterIndex, ((Short)x).shortValue());
break;
case Types.INTEGER:
setInt(parameterIndex, ((Integer)x).intValue());
break;
case Types.BIGINT:
setLong(parameterIndex, ((Long)x).longValue());
break;
case Types.DOUBLE:
setDouble(parameterIndex, ((Double)x).doubleValue());
break;
case Types.DECIMAL:
setBigDecimal(parameterIndex, (BigDecimal)x);
break;
case Types.TIMESTAMP:
setTimestamp(parameterIndex, (Timestamp)x);
break;
case Types.VARBINARY:
case Types.VARCHAR:
case Types.NVARCHAR:
setString(parameterIndex, (String)x);
break;
default:
throw SQLError.get(SQLError.ILLEGAL_ARGUMENT);
}
}
示例10: throwRangeException
private void throwRangeException(String valueAsString, int columnIndex, int jdbcType) throws SQLException {
String datatype = null;
switch (jdbcType) {
case Types.TINYINT:
datatype = "TINYINT";
break;
case Types.SMALLINT:
datatype = "SMALLINT";
break;
case Types.INTEGER:
datatype = "INTEGER";
break;
case Types.BIGINT:
datatype = "BIGINT";
break;
case Types.REAL:
datatype = "REAL";
break;
case Types.FLOAT:
datatype = "FLOAT";
break;
case Types.DOUBLE:
datatype = "DOUBLE";
break;
case Types.DECIMAL:
datatype = "DECIMAL";
break;
default:
datatype = " (JDBC type '" + jdbcType + "')";
}
throw SQLError.createSQLException("'" + valueAsString + "' in column '" + columnIndex + "' is outside valid range for the datatype " + datatype + ".",
SQLError.SQL_STATE_NUMERIC_VALUE_OUT_OF_RANGE, getExceptionInterceptor());
}
示例11: literalize
private String literalize(List<String> v, int type){
StringJoiner sj = new StringJoiner(",", "(",")");
if(type == Types.NUMERIC || type == Types.BIGINT || type == Types.BIT || type == Types.DECIMAL
|| type == Types.DOUBLE || type == Types.FLOAT || type == Types.INTEGER || type == Types.REAL || type == Types.ROWID
|| type == Types.SMALLINT || type == Types.TINYINT){
v.forEach(s -> sj.add(s) );
}else{
v.forEach(s -> sj.add("'" + s + "'") );
}
return sj.toString();
}
示例12: castValue
/**
* For the given string representation of a value, convert it to the proper
* object based on its sqlType
* @param sqlType
* @param value
* @return
* @see java.sql.Types
*/
public static Object castValue(int sqlType, String value) {
Object ret = null;
switch (sqlType) {
case Types.CHAR:
case Types.VARCHAR:
case Types.NCHAR:
case Types.NVARCHAR: {
ret = value;
break;
}
case Types.TINYINT:
case Types.SMALLINT: {
ret = Short.parseShort(value);
break;
}
case Types.INTEGER: {
ret = Integer.parseInt(value);
break;
}
case Types.BIGINT: {
ret = Long.parseLong(value);
break;
}
case Types.BOOLEAN: {
ret = Boolean.parseBoolean(value);
break;
}
case Types.DECIMAL:
case Types.DOUBLE: {
ret = Double.parseDouble(value);
break;
}
case Types.FLOAT: {
ret = Float.parseFloat(value);
break;
}
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP: {
for (DateFormat f : timestamp_formats) {
try {
ret = f.parse(value);
} catch (ParseException ex) {
// Ignore...
}
if (ret != null) break;
} // FOR
if (ret == null) throw new RuntimeException("Failed to parse timestamp '" + value + "'");
break;
}
default:
LOG.warn("Unexpected SQL Type '" + sqlType + "' for value '" + value + "'");
} // SWITCH
return (ret);
}
示例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: 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;
}
示例15: 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;
}
}