当前位置: 首页>>代码示例>>Java>>正文


Java Types.NUMERIC属性代码示例

本文整理汇总了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;
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:23,代码来源:ResultSetMetaData.java

示例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 );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:MySQLDialect.java

示例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;
    }
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:36,代码来源:ResultSetMetaData.java

示例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);
    }
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:25,代码来源:SQLType.java

示例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;
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:37,代码来源:AbstractService.java

示例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;
}
 
开发者ID:DomKing,项目名称:server-utility,代码行数:15,代码来源:JavaTypeResolverDefaultImpl.java

示例7: isBigdecimalValue

public boolean isBigdecimalValue()
{
	if(this.dataType==Types.NUMERIC || this.dataType==Types.DECIMAL)
	{
		return true;
	}
	else
	{
		return false;
	}
}
 
开发者ID:shaogaige,项目名称:iDataBaseConnection,代码行数:11,代码来源:Value.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:JdbcUtils.java

示例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);
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:42,代码来源:ResultSetImpl.java

示例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;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:DataDrivenDBInputFormat.java

示例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;
}
 
开发者ID:drtrang,项目名称:mybatis-generator-extension,代码行数:15,代码来源:CustomJavaTypeResolver.java

示例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;
   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:60,代码来源:JavaSqlConversion.java

示例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;
}
 
开发者ID:shaogaige,项目名称:iDataBaseConnection,代码行数:66,代码来源:ResultSetUtil.java

示例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;
    }

}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:51,代码来源:UpdatableResultSet.java

示例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 + ")");
  }
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:50,代码来源:DatabaseMetaDataProvider.java


注:本文中的java.sql.Types.NUMERIC属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。