本文整理汇总了Java中java.sql.Types.NUMERIC属性的典型用法代码示例。如果您正苦于以下问题:Java Types.NUMERIC属性的具体用法?Java Types.NUMERIC怎么用?Java Types.NUMERIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.NUMERIC属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: getCastTypeName
@Override
public String getCastTypeName(int code) {
switch ( code ) {
case Types.INTEGER:
case Types.BIGINT:
case Types.SMALLINT:
return "signed";
case Types.FLOAT:
case Types.NUMERIC:
case Types.REAL:
return "decimal";
case Types.VARCHAR:
return "char";
case Types.VARBINARY:
return "binary";
default:
return super.getCastTypeName( code );
}
}
示例3: 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;
}
}
示例4: getType
@Override
public SQLType getType(int sqlCode, String typeName) {
switch (sqlCode) {
case Types.BIT: return SQLType.BIT;
case Types.BOOLEAN: return SQLType.BOOLEAN;
case Types.INTEGER: return SQLType.INTEGER;
case Types.TINYINT: return SQLType.TINYINT;
case Types.SMALLINT: return SQLType.SMALLINT;
case Types.BIGINT: return SQLType.BIGINT;
case Types.DOUBLE: return SQLType.DOUBLE;
case Types.NUMERIC: return SQLType.NUMERIC;
case Types.DECIMAL: return SQLType.DECIMAL;
case Types.FLOAT: return SQLType.FLOAT;
case Types.REAL: return SQLType.REAL;
case Types.NVARCHAR: return SQLType.NVARCHAR;
case Types.CHAR: return SQLType.CHAR;
case Types.VARCHAR: return SQLType.VARCHAR;
case Types.CLOB: return SQLType.CLOB;
case Types.DATE: return SQLType.DATE;
case Types.TIME: return SQLType.TIME;
case Types.TIMESTAMP: return SQLType.DATETIME;
default:
throw new RuntimeException("Unsupported data type for " + typeName + ", sqlType: " + sqlCode);
}
}
示例5: finagle
ColumnMetaData finagle(ColumnMetaData column) {
switch (column.type.rep) {
case BYTE:
case PRIMITIVE_BYTE:
case DOUBLE:
case PRIMITIVE_DOUBLE:
case FLOAT:
case PRIMITIVE_FLOAT:
case INTEGER:
case PRIMITIVE_INT:
case SHORT:
case PRIMITIVE_SHORT:
case LONG:
case PRIMITIVE_LONG:
return column.setRep(ColumnMetaData.Rep.NUMBER);
default:
// continue
break;
}
switch (column.type.id) {
case Types.VARBINARY:
case Types.BINARY:
switch (getSerializationType()) {
case JSON:
return column.setRep(ColumnMetaData.Rep.STRING);
case PROTOBUF:
return column;
default:
throw new IllegalStateException("Unhadled case statement");
}
case Types.DECIMAL:
case Types.NUMERIC:
return column.setRep(ColumnMetaData.Rep.NUMBER);
default:
return column;
}
}
示例6: 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;
}
示例7: isBigdecimalValue
public boolean isBigdecimalValue()
{
if(this.dataType==Types.NUMERIC || this.dataType==Types.DECIMAL)
{
return true;
}
else
{
return false;
}
}
示例8: isNumeric
/**
* Check whether the given SQL type is numeric.
* @param sqlType the SQL type to be checked
* @return whether the type is numeric
*/
public static boolean isNumeric(int sqlType) {
return Types.BIT == sqlType || Types.BIGINT == sqlType || Types.DECIMAL == sqlType ||
Types.DOUBLE == sqlType || Types.FLOAT == sqlType || Types.INTEGER == sqlType ||
Types.NUMERIC == sqlType || Types.REAL == sqlType || Types.SMALLINT == sqlType ||
Types.TINYINT == sqlType;
}
示例9: getNativeBigDecimal
/**
* Get the value of a column in the current row as a java.math.BigDecimal
* object
*
* @param columnIndex
* the first column is 1, the second is 2...
* @param scale
* the number of digits to the right of the decimal
*
* @return the column value; if the value is SQL NULL, null
*
* @exception SQLException
* if a database access error occurs
*/
protected BigDecimal getNativeBigDecimal(int columnIndex, int scale) throws SQLException {
checkColumnBounds(columnIndex);
String stringVal = null;
Field f = this.fields[columnIndex - 1];
Object value = this.thisRow.getColumnValue(columnIndex - 1);
if (value == null) {
this.wasNullFlag = true;
return null;
}
this.wasNullFlag = false;
switch (f.getSQLType()) {
case Types.DECIMAL:
case Types.NUMERIC:
stringVal = StringUtils.toAsciiString((byte[]) value);
break;
default:
stringVal = getNativeString(columnIndex);
}
return getBigDecimalFromString(stringVal, columnIndex, scale);
}
示例10: 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;
}
}
示例11: 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;
}
示例12: fromSqlToJava
/**
* Decode the String param type passed by user on client side into a Types
* corresponding value.
*
* @param sqlParamType
* @return
*/
public static int fromSqlToJava(String sqlParamType) {
int javaType = 0;
if (sqlParamType.equals(AceQLTypes.CHARACTER)) {
javaType = Types.CHAR;
} else if (sqlParamType.equals(AceQLTypes.VARCHAR)) {
javaType = Types.VARCHAR;
} else if (sqlParamType.equals(AceQLTypes.LONGVARCHAR)) {
javaType = Types.LONGVARCHAR;
} else if (sqlParamType.equals(AceQLTypes.BIT)) {
javaType = Types.BIT;
} else if (sqlParamType.equals(AceQLTypes.NUMERIC)) {
javaType = Types.NUMERIC;
} else if (sqlParamType.equals(AceQLTypes.TINYINT)) {
javaType = Types.TINYINT;
} else if (sqlParamType.equals(AceQLTypes.SMALLINT)) {
javaType = Types.SMALLINT;
} else if (sqlParamType.equals(AceQLTypes.INTEGER)) {
javaType = Types.INTEGER;
} else if (sqlParamType.equals(AceQLTypes.BIGINT)) {
javaType = Types.BIGINT;
} else if (sqlParamType.equals(AceQLTypes.REAL)) {
javaType = Types.REAL;
} else if (sqlParamType.equals(AceQLTypes.FLOAT)) {
javaType = Types.FLOAT;
} else if (sqlParamType.equals(AceQLTypes.DOUBLE_PRECISION)) {
javaType = Types.DOUBLE;
} else if (sqlParamType.equals(AceQLTypes.DATE)) {
javaType = Types.DATE;
} else if (sqlParamType.equals(AceQLTypes.TIME)) {
javaType = Types.TIME;
} else if (sqlParamType.equals(AceQLTypes.TIMESTAMP)) {
javaType = Types.TIMESTAMP;
} else if (sqlParamType.equals(AceQLTypes.BINARY)) {
javaType = Types.BINARY;
} else if (sqlParamType.equals(AceQLTypes.VARBINARY)) {
javaType = Types.VARBINARY;
} else if (sqlParamType.equals(AceQLTypes.DATE)) {
javaType = Types.LONGVARBINARY;
} else if (sqlParamType.equals(AceQLTypes.BLOB)) {
javaType = Types.BLOB;
} else if (sqlParamType.equals(AceQLTypes.CLOB)) {
javaType = Types.CLOB;
} else if (sqlParamType.startsWith("TYPE_NULL")) {
String javaTypeStr = StringUtils.substringAfter(sqlParamType,
"TYPE_NULL");
javaType = Integer.parseInt(javaTypeStr);
} else {
throw new IllegalArgumentException(
"Unsuported data type for null setting: " + sqlParamType);
}
return javaType;
}
示例13: getValue
private static Value getValue(String columnName,int type,ResultSet rs)
{
Value value = new Value(type);
try
{
switch(type)
{
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
case Types.NCHAR:
case Types.NVARCHAR:
case Types.LONGNVARCHAR:
value.setString_value(rs.getString(columnName));
break;
case Types.FLOAT:
case Types.DOUBLE:
value.setDouble_value(rs.getDouble(columnName));
break;
case Types.INTEGER:
case Types.SMALLINT:
value.setInt_value(rs.getInt(columnName));
break;
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
value.setBytes_value(rs.getBytes(columnName));
break;
case Types.BLOB:
value.setBlob_value(rs.getBlob(columnName));
break;
case Types.NUMERIC:
case Types.DECIMAL:
value.setBigdecimal_value(rs.getBigDecimal(columnName));
break;
case Types.BIT:
case Types.BOOLEAN:
value.setBoolean_value(rs.getBoolean(columnName));
break;
case Types.TINYINT:
value.setByte_value(rs.getByte(columnName));
break;
case Types.BIGINT:
value.setLong_value(rs.getLong(columnName));
break;
case Types.REAL:
value.setFloat_value(rs.getFloat(columnName));
break;
case Types.DATE:
value.setDate_value(rs.getDate(columnName));
break;
case Types.TIME:
case Types.TIMESTAMP:
value.setTime_value(rs.getTime(columnName));
break;
default:
value.setObject_value(rs.getObject(columnName));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
DBCException.logException(DBCException.E_ResultSet, e);
return null;
}
return value;
}
示例14: 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;
}
}
示例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 + ")");
}
}