List of usage examples for java.sql Types NUMERIC
int NUMERIC
To view the source code for java.sql Types NUMERIC.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NUMERIC
.
From source file:org.apache.ojb.broker.metadata.FieldTypeClasses.java
/** * Returns a {@link FieldType} instance for the given sql type * (see {@link java.sql.Types}) as specified in JDBC 3.0 specification * (see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>). * * @param jdbcType Specify the type to look for. * @return A new specific {@link FieldType} instance. *///from w ww . ja v a2s . c o m static FieldType newFieldType(JdbcType jdbcType) { FieldType result = null; switch (jdbcType.getType()) { case Types.ARRAY: result = new ArrayFieldType(); break; case Types.BIGINT: result = new LongFieldType(); break; case Types.BINARY: result = new ByteArrayFieldType(); break; case Types.BIT: result = new BooleanFieldType(); break; case Types.BLOB: result = new BlobFieldType(); break; case Types.CHAR: result = new StringFieldType(); break; case Types.CLOB: result = new ClobFieldType(); break; case Types.DATE: result = new DateFieldType(); break; case Types.DECIMAL: result = new BigDecimalFieldType(); break; // Not needed, user have to use the underlying sql datatype in OJB mapping files // case Types.DISTINCT: // result = new DistinctFieldType(); // break; case Types.DOUBLE: result = new DoubleFieldType(); break; case Types.FLOAT: result = new FloatFieldType(); break; case Types.INTEGER: result = new IntegerFieldType(); break; case Types.JAVA_OBJECT: result = new JavaObjectFieldType(); break; case Types.LONGVARBINARY: result = new ByteArrayFieldType(); break; case Types.LONGVARCHAR: result = new StringFieldType(); break; case Types.NUMERIC: result = new BigDecimalFieldType(); break; case Types.REAL: result = new FloatFieldType(); break; case Types.REF: result = new RefFieldType(); break; case Types.SMALLINT: result = new ShortFieldType(); break; case Types.STRUCT: result = new StructFieldType(); break; case Types.TIME: result = new TimeFieldType(); break; case Types.TIMESTAMP: result = new TimestampFieldType(); break; case Types.TINYINT: result = new ByteFieldType(); break; case Types.VARBINARY: result = new ByteArrayFieldType(); break; case Types.VARCHAR: result = new StringFieldType(); break; case Types.OTHER: result = new JavaObjectFieldType(); break; // // case Types.NULL: // result = new NullFieldType(); // break; //#ifdef JDBC30 case Types.BOOLEAN: result = new BooleanFieldType(); break; case Types.DATALINK: result = new URLFieldType(); break; //#endif default: throw new OJBRuntimeException("Unkown or not supported field type specified, specified jdbc type was '" + jdbcType + "', as string: " + JdbcTypesHelper.getSqlTypeAsString(jdbcType.getType())); } // make sure that the sql type was set result.setSqlType(jdbcType); return result; }
From source file:org.jpos.qi.system.SQLQueryObject.java
private boolean isNumericDataType(int type) { switch (type) { case Types.BIGINT: 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; default:/*from www . ja va 2 s . c o m*/ return false; } }
From source file:org.jumpmind.db.platform.h2.H2DdlBuilder.java
public H2DdlBuilder() { super(DatabaseNamesConstants.H2); databaseInfo.setNonPKIdentityColumnsSupported(false); databaseInfo.setIdentityOverrideAllowed(false); databaseInfo.setSystemForeignKeyIndicesAlwaysNonUnique(true); databaseInfo.setNullAsDefaultValueRequired(false); databaseInfo.addNativeTypeMapping(Types.ARRAY, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.DISTINCT, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.NULL, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.REF, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.STRUCT, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.DATALINK, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.BIT, "BOOLEAN", Types.BIT); databaseInfo.addNativeTypeMapping(Types.NUMERIC, "DECIMAL", Types.DECIMAL); databaseInfo.addNativeTypeMapping(Types.BINARY, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.BLOB, "BLOB", Types.BLOB); databaseInfo.addNativeTypeMapping(Types.CLOB, "CLOB", Types.CLOB); databaseInfo.addNativeTypeMapping(Types.LONGVARCHAR, "VARCHAR(" + Integer.MAX_VALUE + ")", Types.VARCHAR); databaseInfo.addNativeTypeMapping(Types.FLOAT, "DOUBLE", Types.DOUBLE); databaseInfo.addNativeTypeMapping(Types.JAVA_OBJECT, "OTHER"); databaseInfo.setDefaultSize(Types.CHAR, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.VARCHAR, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.BINARY, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.VARBINARY, Integer.MAX_VALUE); databaseInfo.setNonBlankCharColumnSpacePadded(false); databaseInfo.setBlankCharColumnSpacePadded(false); databaseInfo.setCharColumnSpaceTrimmed(true); databaseInfo.setEmptyStringNulled(false); databaseInfo.setNullAsDefaultValueRequired(true); }
From source file:org.apache.kylin.jdbc.KylinClient.java
@SuppressWarnings("rawtypes") public static Class convertType(int sqlType) { Class result = Object.class; switch (sqlType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: result = String.class; break;//from w ww . j a va 2 s . c om case Types.NUMERIC: case Types.DECIMAL: result = BigDecimal.class; break; case Types.BIT: result = Boolean.class; break; case Types.TINYINT: result = Byte.class; break; case Types.SMALLINT: result = Short.class; break; case Types.INTEGER: result = Integer.class; break; case Types.BIGINT: result = Long.class; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = Double.class; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = Byte[].class; break; case Types.DATE: result = Date.class; break; case Types.TIME: result = Time.class; break; case Types.TIMESTAMP: result = Timestamp.class; break; default: //do nothing break; } return result; }
From source file:net.sourceforge.vulcan.spring.jdbc.BuildInserter.java
public BuildInserter(DataSource dataSource) { setDataSource(dataSource);//from w ww . j a va 2 s. c o m setSql("insert into builds " + "(project_id, uuid, status, message_key," + "message_arg_0, message_arg_1, message_arg_2, message_arg_3, " + "build_reason_key, " + "build_reason_arg_0, build_reason_arg_1, build_reason_arg_2, build_reason_arg_3, " + "start_date, completion_date, build_number, update_type," + "work_dir, revision, revision_label, last_good_build_number," + "tag_name, repository_url, status_changed, scheduled_build," + "requested_by, revision_unavailable, broken_by_user_id, claimed_date, work_dir_vcs_clean) " + "values ((select id from project_names where name=?)," + " ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + " (select id from users where username=?), ?, ?)"); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.TIMESTAMP)); declareParameter(new SqlParameter(Types.TIMESTAMP)); declareParameter(new SqlParameter(Types.NUMERIC)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.BIGINT)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.NUMERIC)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.BOOLEAN)); declareParameter(new SqlParameter(Types.BOOLEAN)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.BOOLEAN)); declareParameter(new SqlParameter(Types.VARCHAR)); declareParameter(new SqlParameter(Types.TIMESTAMP)); declareParameter(new SqlParameter(Types.BOOLEAN)); compile(); }
From source file:architecture.ee.web.community.profile.dao.jdbc.JdbcProfileDao.java
public void removeProfileImage(ProfileImage image) { getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.DELETE_PROFILE_IMAGE_BY_ID").getSql(), new SqlParameterValue(Types.NUMERIC, image.getProfileImageId())); getExtendedJdbcTemplate().update(// www.j a va 2 s . co m getBoundSql("ARCHITECTURE_COMMUNITY.DELETE_PROFILE_IMAGE_DATA_BY_ID").getSql(), new SqlParameterValue(Types.NUMERIC, image.getProfileImageId())); }
From source file:io.lightlink.oracle.AbstractOracleType.java
protected ARRAY createArray(Connection con, Object value, String typeName) throws SQLException { if (value == null) return null; ArrayDescriptor arrayStructDesc = safeCreateArrayDescriptor(typeName, con); if (value == null) return null; if (value.getClass().isArray()) { value = Arrays.asList((Object[]) value); }/* w w w .ja v a2 s .c o m*/ List records = (List) value; String baseName = arrayStructDesc.getBaseName(); int baseType = arrayStructDesc.getBaseType(); if (baseType == Types.VARCHAR || baseType == Types.CHAR || baseType == Types.CLOB || baseType == Types.NUMERIC || baseType == Types.INTEGER || baseType == Types.BIGINT || baseType == Types.FLOAT || baseType == Types.DOUBLE || baseType == Types.DECIMAL || baseType == Types.NCHAR || baseType == Types.NVARCHAR || baseType == Types.NCLOB) { return new ARRAY(arrayStructDesc, con, records.toArray()); // primitive array } else { Object[] structArray = new Object[records.size()]; for (int i = 0; i < structArray.length; i++) { Object record = records.get(i); if (baseType == OracleTypes.JAVA_STRUCT || baseType == OracleTypes.JAVA_OBJECT || baseType == OracleTypes.STRUCT || baseType == OracleTypes.JAVA_STRUCT) { record = createStruct(con, record, baseName); } else if (baseType == OracleTypes.ARRAY) { record = createArray(con, record, baseName); } structArray[i] = record; } return new ARRAY(arrayStructDesc, con, structArray); } }
From source file:architecture.ee.web.community.timeline.dao.jdbc.JdbcTimelineDao.java
public Timeline getTimelineById(long timelineId) throws TimelineNotFoundException { try {/* ww w. jav a 2 s. c om*/ Timeline timeline = getExtendedJdbcTemplate().queryForObject( getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_TIMELINE_BY_ID").getSql(), timelineMapper, new SqlParameterValue(Types.NUMERIC, timelineId)); return timeline; } catch (DataAccessException e) { throw new TimelineNotFoundException(e); } }
From source file:org.castor.cpa.persistence.sql.keygen.MaxKeyGenerator.java
/** * Initialize the MAX key generator./*from w w w .j a v a2s .c o m*/ * * @param factory A PersistenceFactory instance. * @param sqlType A SQLTypidentifier. * @throws MappingException if this key generator is not compatible with the * persistance factory. */ public MaxKeyGenerator(final PersistenceFactory factory, final int sqlType) throws MappingException { super(factory); _factory = factory; if ((sqlType != Types.INTEGER) && (sqlType != Types.BIGINT) && (sqlType != Types.NUMERIC) && (sqlType != Types.DECIMAL)) { String msg = Messages.format("mapping.keyGenSQLType", getClass().getName(), new Integer(sqlType)); throw new MappingException(msg); } initSqlTypeHandler(sqlType); }
From source file:com.squid.core.jdbc.formatter.DefaultJDBCDataFormatter.java
public String formatJDBCObject(final Object jdbcObject, final int colType) throws SQLException { String value = ""; switch (colType) { case Types.BIT: if (jdbcObject != null) { value = String.valueOf(jdbcObject); }//from w w w . j a va 2 s .c o m break; case Types.BOOLEAN: if (jdbcObject != null) { value = new Boolean(jdbcObject.toString()).toString(); } break; case Types.BIGINT: case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.REAL: case Types.NUMERIC: if (jdbcObject != null) { value = "" + formatter.formatDecimal(jdbcObject); } break; case Types.INTEGER: case Types.TINYINT: case Types.SMALLINT: if (jdbcObject != null) { value = "" + formatter.formatDecimal(jdbcObject); } break; case Types.CLOB: if (jdbcObject != null) { try { value = read((Clob) jdbcObject); } catch (SQLException sqle) { value = ""; } catch (IOException ioe) { value = ""; } } break; case Types.ARRAY: try { ResultSet rs = ((Array) jdbcObject).getResultSet(); int arrayType = ((Array) jdbcObject).getBaseType(); boolean isNotNew = false; while (rs.next()) { String current = formatJDBCObject(rs.getObject(2), arrayType); if ("".equals(current.trim()) == false) { if (isNotNew) { value = value + ","; } else { isNotNew = !isNotNew; } value = value + current; } } if ("".equals(value) == false) { value = "{" + value + "}"; } } catch (SQLException sqle) { value = ""; } break; case Types.JAVA_OBJECT: if (jdbcObject != null) { value = String.valueOf(jdbcObject); } break; case Types.DATE: if (jdbcObject != null) { value = formatter.formatDate(jdbcObject); } break; case Types.TIME: if (jdbcObject != null) { value = ((Time) jdbcObject).toString(); } break; case Types.TIMESTAMP: if (jdbcObject != null) { value = formatter.formatTimestamp(jdbcObject); } break; case Types.LONGVARCHAR: case Types.VARCHAR: case Types.CHAR: if (jdbcObject != null) { value = jdbcObject.toString(); } else { value = "NULL"; } break; case Types.BINARY: value = new String((byte[]) jdbcObject); break; default: value = ""; } if (value == null) { value = ""; } return value; }