本文整理汇总了Java中java.sql.Types.FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Java Types.FLOAT属性的具体用法?Java Types.FLOAT怎么用?Java Types.FLOAT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.Types
的用法示例。
在下文中一共展示了Types.FLOAT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassName
public static String getClassName(int sqlType)
{
if (sqlType == Types.BOOLEAN)
return Boolean.class.getName();
if (sqlType == Types.BINARY)
return Byte[].class.getName();
if (sqlType == Types.DATE)
return Date.class.getName();
if (sqlType == Types.DOUBLE || sqlType == Types.FLOAT || sqlType == Types.DECIMAL)
return Double.class.getName();
if (sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.TINYINT)
return Long.class.getName();
if (sqlType == Types.NVARCHAR)
return String.class.getName();
if (sqlType == Types.TIMESTAMP)
return Timestamp.class.getName();
if (sqlType == Types.ARRAY)
return Object.class.getName();
return null;
}
示例2: isNumeric
public static boolean isNumeric(int jdbcType) {
switch (jdbcType) {
case Types.BIT:
case Types.BIGINT:
case Types.BOOLEAN:
case Types.INTEGER:
case Types.SMALLINT:
case Types.TINYINT:
case Types.FLOAT:
case Types.REAL:
case Types.DOUBLE:
case Types.DECIMAL:
case Types.NUMERIC:
return true;
default:
return false;
}
}
示例3: 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;
}
示例4: 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";
}
}
示例5: 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() + "\"";
}
}
示例6: 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;
}
}
示例7: isFloatingPointNumber
@Override
public boolean isFloatingPointNumber(int index) throws SQLException {
if (this.isBinaryEncoded) {
switch (this.metadata[index].getSQLType()) {
case Types.FLOAT:
case Types.DOUBLE:
case Types.DECIMAL:
case Types.NUMERIC:
return true;
default:
return false;
}
}
findAndSeekToOffset(index);
long length = this.rowFromServer.readFieldLength();
if (length == Buffer.NULL_LENGTH) {
return false;
}
if (length == 0) {
return false;
}
int offset = this.rowFromServer.getPosition();
byte[] buffer = this.rowFromServer.getByteBuffer();
for (int i = 0; i < (int) length; i++) {
char c = (char) buffer[offset + i];
if ((c == 'e') || (c == 'E')) {
return true;
}
}
return false;
}
示例8: 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;
}
}
示例9: 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();
}
示例10: 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"}
};
}
示例11: getColumnType
public int getColumnType(int column) throws SQLException{
int type = CIL.unbox_int( getColumnMeta(column, "ProviderType") );
switch(type){
case OdbcType.VarChar:
return Types.VARCHAR;
case OdbcType.Char:
return Types.CHAR;
case OdbcType.Binary:
case OdbcType.Timestamp:
return Types.BINARY;
case OdbcType.Bit:
return Types.BOOLEAN;
case OdbcType.TinyInt:
return Types.TINYINT;
case OdbcType.Date:
return Types.DATE;
case OdbcType.DateTime:
case OdbcType.SmallDateTime:
return Types.TIMESTAMP;
case OdbcType.Decimal:
return Types.DECIMAL;
case OdbcType.Double:
return Types.DOUBLE;
case OdbcType.UniqueIdentifier:
return Types.ROWID;
case OdbcType.SmallInt:
return Types.SMALLINT;
case OdbcType.Int:
return Types.INTEGER;
case OdbcType.BigInt:
return Types.BIGINT;
case OdbcType.Real:
return Types.FLOAT;
case OdbcType.NVarChar:
return Types.NVARCHAR;
case OdbcType.NChar:
return Types.NCHAR;
case OdbcType.NText:
return Types.LONGNVARCHAR;
case OdbcType.Text:
return Types.LONGVARCHAR;
case OdbcType.Image:
return Types.LONGVARBINARY;
case OdbcType.Time:
return Types.TIME;
case OdbcType.Numeric:
return Types.NUMERIC;
case OdbcType.VarBinary:
return Types.VARBINARY;
}
return Types.OTHER;
}
示例12: 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);
}
}
示例13: getSplitter
/**
* @return the DBSplitter implementation to use to divide the table/query
* into InputSplits.
*/
public DBSplitter getSplitter(int sqlDataType, long splitLimit, String rangeStyle) {
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(rangeStyle);
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(rangeStyle);
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: 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: setFloat
/**
* Set a parameter to a Java float value. The driver converts this to a SQL
* FLOAT value when it sends it to the database.
*
* @param parameterIndex
* the first parameter is 1...
* @param x
* the parameter value
*
* @exception SQLException
* if a database access error occurs
*/
public void setFloat(int parameterIndex, float x) throws SQLException {
setInternal(parameterIndex, StringUtils.fixDecimalExponent(String.valueOf(x)));
this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.FLOAT;
}