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:architecture.ee.web.community.page.dao.jdbc.JdbcPageDao.java
private Page load(long pageId, int versionNumber) { if (pageId <= 0) return null; final Page page = new DefaultPage(); page.setPageId(pageId);//from w w w . j av a 2 s. co m page.setVersionId(versionNumber); getExtendedJdbcTemplate().query( getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_PAGE_BY_ID_AND_VERSION").getSql(), new RowMapper<Page>() { public Page mapRow(ResultSet rs, int rowNum) throws SQLException { page.setName(rs.getString("NAME")); page.setObjectType(rs.getInt("OBJECT_TYPE")); page.setObjectId(rs.getLong("OBJECT_ID")); page.setPageState(PageState.valueOf(rs.getString("STATE").toUpperCase())); page.setUser(new UserTemplate(rs.getLong("USER_ID"))); if (rs.wasNull()) page.setUser(new UserTemplate(-1L)); page.setTitle(rs.getString("TITLE")); page.setSummary(rs.getString("SUMMARY")); page.setCreationDate(rs.getTimestamp("CREATION_DATE")); page.setModifiedDate(rs.getTimestamp("MODIFIED_DATE")); return page; } }, new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, page.getVersionId())); if (page.getName() == null) return null; try { BodyContent bodyContent = getExtendedJdbcTemplate().queryForObject( getBoundSql("ARCHITECTURE_COMMUNITY.SELECT_PAGE_BODY").getSql(), bodyContentMapper, new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, page.getVersionId())); page.setBodyContent(bodyContent); } catch (EmptyResultDataAccessException e) { } if (page.getBodyText() == null) { long bodyId = -1L; try { bodyId = getExtendedJdbcTemplate().queryForObject( getBoundSql("ARCHITECTURE_COMMUNITY.DELETE_PAGE_BODY_VERSION").getSql(), Long.class, new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, page.getVersionId())); } catch (EmptyResultDataAccessException e) { } } Map<String, String> properties = loadProperties(page); page.getProperties().putAll(properties); return page; }
From source file:org.nuclos.server.dblayer.impl.standard.StandardSqlDBAccess.java
protected static DbGenericType getDbGenericType(int sqlType, String typeName) { switch (sqlType) { case Types.VARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.CHAR: return DbGenericType.VARCHAR; case Types.NUMERIC: case Types.DECIMAL: return DbGenericType.NUMERIC; case Types.BIT: case Types.BOOLEAN: return DbGenericType.BOOLEAN; case Types.DATE: return DbGenericType.DATE; case Types.BLOB: case Types.VARBINARY: case Types.BINARY: case Types.LONGVARBINARY: return DbGenericType.BLOB; case Types.CLOB: case Types.LONGVARCHAR: return DbGenericType.CLOB; case Types.TIMESTAMP: return DbGenericType.DATETIME; default:// w w w . j a v a 2 s . com return null; } }
From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java
public static String getJavaDatatype(int colType) { switch (colType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return "java.lang.String"; case Types.NUMERIC: case Types.DECIMAL: return "java.math.BigDecimal"; case Types.BIT: return "boolean"; case Types.TINYINT: return "byte"; case Types.SMALLINT: return "short"; case Types.INTEGER: return "int"; case Types.BIGINT: return "long"; case Types.REAL: return "float"; case Types.FLOAT: case Types.DOUBLE: return "double"; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return "byte[]"; case Types.DATE: return "java.sql.Date"; case Types.TIME: return "java.sql.Time"; case Types.TIMESTAMP: return "java.sql.Timestamp"; case Types.OTHER: return "java.lang.Object"; default:// w w w . j a v a 2 s . c o m return null; } }
From source file:com.flexive.ejb.beans.structure.AssignmentEngineBean.java
private void storeOptions(Connection con, String table, String primaryColumn, long primaryId, Long assignmentId, List<FxStructureOption> options) throws SQLException, FxInvalidParameterException { PreparedStatement ps = null;//from w w w . java2 s. c o m try { if (assignmentId == null) { ps = con.prepareStatement( "DELETE FROM " + table + " WHERE " + primaryColumn + "=? AND ASSID IS NULL"); } else { ps = con.prepareStatement("DELETE FROM " + table + " WHERE " + primaryColumn + "=? AND ASSID=?"); ps.setLong(2, assignmentId); } ps.setLong(1, primaryId); ps.executeUpdate(); if (options == null || options.size() == 0) return; ps.close(); ps = con.prepareStatement("INSERT INTO " + table + " (" + primaryColumn + ",ASSID,OPTKEY,MAYOVERRIDE,ISINHERITED,OPTVALUE)VALUES(?,?,?,?,?,?)"); for (FxStructureOption option : options) { ps.setLong(1, primaryId); if (assignmentId != null) ps.setLong(2, assignmentId); else ps.setNull(2, java.sql.Types.NUMERIC); if (StringUtils.isEmpty(option.getKey())) throw new FxInvalidParameterException("key", "ex.structure.option.key.empty", option.getValue()); ps.setString(3, option.getKey()); ps.setBoolean(4, option.isOverridable()); ps.setBoolean(5, option.getIsInherited()); ps.setString(6, option.getValue()); ps.addBatch(); } ps.executeBatch(); } finally { if (ps != null) ps.close(); } }
From source file:org.pentaho.di.jdbc.Support.java
/** * Retrieve the fully qualified java class name for the * supplied JDBC Types constant./*from w ww . j a v a2 s . c om*/ * * @param jdbcType The JDBC Types constant. * @return The fully qualified java class name as a <code>String</code>. */ static String getClassName(int jdbcType) { switch (jdbcType) { case java.sql.Types.BOOLEAN: case java.sql.Types.BIT: return "java.lang.Boolean"; case java.sql.Types.TINYINT: case java.sql.Types.SMALLINT: case java.sql.Types.INTEGER: return "java.lang.Integer"; case java.sql.Types.BIGINT: return "java.lang.Long"; case java.sql.Types.NUMERIC: case java.sql.Types.DECIMAL: return "java.math.BigDecimal"; case java.sql.Types.REAL: return "java.lang.Float"; case java.sql.Types.FLOAT: case java.sql.Types.DOUBLE: return "java.lang.Double"; case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: return "java.lang.String"; case java.sql.Types.BINARY: case java.sql.Types.VARBINARY: return "[B"; case java.sql.Types.LONGVARBINARY: case java.sql.Types.BLOB: return "java.sql.Blob"; case java.sql.Types.LONGVARCHAR: case java.sql.Types.CLOB: return "java.sql.Clob"; case java.sql.Types.DATE: return "java.sql.Date"; case java.sql.Types.TIME: return "java.sql.Time"; case java.sql.Types.TIMESTAMP: return "java.sql.Timestamp"; default: break; } return "java.lang.Object"; }
From source file:org.jumpmind.symmetric.db.ase.AseTriggerTemplate.java
@Override protected String buildKeyVariablesDeclare(Column[] columns, String prefix) { String text = ""; for (int i = 0; i < columns.length; i++) { text += "declare @" + prefix + "pk" + i + " "; switch (columns[i].getMappedTypeCode()) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: // ASE does not support bigint text += "NUMERIC(18,0)\n"; break; case Types.NUMERIC: case Types.DECIMAL: // Use same default scale and precision used by Sybase ASA // for a decimal with unspecified scale and precision. text += "decimal(30,6)\n"; break; case Types.FLOAT: case Types.REAL: case Types.DOUBLE: text += "float\n"; break; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: text += "varchar(1000)\n"; break; case Types.DATE: text += "date\n"; break; case Types.TIME: text += "time\n"; break; case Types.TIMESTAMP: text += "datetime\n"; break; case Types.BOOLEAN: case Types.BIT: text += "bit\n"; break; case Types.CLOB: text += "varchar(32767)\n"; break; case Types.BLOB: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case -10: // SQL-Server ntext binary type text += "varbinary(32767)\n"; break; case Types.OTHER: text += "varbinary(32767)\n"; break; default://from ww w . j a v a2 s . c o m if (columns[i].getJdbcTypeName() != null && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) { text += "interval"; break; } throw new NotImplementedException(columns[i] + " is of type " + columns[i].getMappedType()); } } return text; }
From source file:org.apache.ctakes.ytex.uima.mapper.DocumentMapperServiceImpl.java
/** * load mapping info// ww w .j av a 2 s .c o m * * @param type * @return */ private AnnoMappingInfo initMapInfo(final FeatureStructure fs) { final Type type = fs.getType(); final String annoName = type.getShortName().toLowerCase(); AnnoMappingInfo mapInfoTmp; final UimaType ut = uimaTypeMap.get(type.getName()); if (this.mapAnnoMappingInfo.containsKey(type.getName())) { mapInfoTmp = this.mapAnnoMappingInfo.get(type.getName()).deepCopy(); } else { mapInfoTmp = new AnnoMappingInfo(); } final AnnoMappingInfo mapInfo = mapInfoTmp; if (ut != null) mapInfo.setUimaTypeId(ut.getUimaTypeID()); // first see if the table name has been set in beans-uima.xml if (Strings.isNullOrEmpty(mapInfo.getTableName())) { // next see if the table name has been set in ref_uima_type if (ut != null && !Strings.isNullOrEmpty(ut.getTableName())) mapInfo.setTableName(ut.getTableName()); else // default to anno_[short name] mapInfo.setTableName("anno_" + annoName); } final List<Feature> features = type.getFeatures(); // get the non primitive fields for (Feature f : features) { if (f.getRange().isArray() && !f.getRange().getComponentType().isPrimitive()) { // add this field to the list of fields to store this.tl_mapFieldInfo.get().put(type.getName(), f.getShortName()); } } this.sessionFactory.getCurrentSession().doWork(new Work() { @Override public void execute(Connection conn) throws SQLException { ResultSet rs = null; try { DatabaseMetaData dmd = conn.getMetaData(); // get columns for corresponding table // mssql - add schema prefix // oracle - convert table name to upper case rs = dmd.getColumns(null, "mssql".equals(dbType) || "hsql".equals(dbType) ? dbSchema : null, "orcl".equals(dbType) || "hsql".equals(dbType) ? mapInfo.getTableName().toUpperCase() : mapInfo.getTableName(), null); while (rs.next()) { String colName = rs.getString("COLUMN_NAME"); int colSize = rs.getInt("COLUMN_SIZE"); int dataType = rs.getInt("DATA_TYPE"); if ("anno_base_id".equalsIgnoreCase(colName)) { // skip anno_base_id continue; } if ("uima_type_id".equalsIgnoreCase(colName)) { // see if there is a uima_type_id column // for FeatureStructures that are not annotations // there can be a field for the uima_type_id if (!(fs instanceof Annotation) && Strings.isNullOrEmpty(mapInfo.getUimaTypeIdColumnName())) { mapInfo.setUimaTypeIdColumnName(colName); } } else if ("coveredText".equalsIgnoreCase(colName)) { // see if there is a coveredText column, store the // covered // text here ColumnMappingInfo coveredTextColumn = new ColumnMappingInfo(); coveredTextColumn.setColumnName(colName); mapInfo.setCoveredTextColumn(coveredTextColumn); coveredTextColumn.setSize(colSize); } else { // possibility 1: the column is already mapped to // the field // if so, then just set the size if (!updateSize(mapInfo, colName, colSize, dataType)) { // possibility 2: the column is not mapped - see // if // it matches a field // iterate through features, see which match the // column for (Feature f : features) { String annoFieldName = f.getShortName(); if (f.getRange().isPrimitive() && annoFieldName.equalsIgnoreCase(colName)) { // primitive attribute ColumnMappingInfo fmap = new ColumnMappingInfo(); fmap.setAnnoFieldName(annoFieldName); fmap.setColumnName(colName); fmap.setSize(colSize); fmap.setSqlType(dataType); mapInfo.getMapField().put(colName, fmap); break; } else if (!f.getRange().isArray() && !f.getRange().isPrimitive() && annoFieldName.equalsIgnoreCase(colName) && (dataType == Types.INTEGER || dataType == Types.SMALLINT || dataType == Types.BIGINT || dataType == Types.NUMERIC || dataType == Types.FLOAT || dataType == Types.DOUBLE)) { // this feature is a reference to // another // annotation. // this column is numeric - a match ColumnMappingInfo fmap = new ColumnMappingInfo(); fmap.setAnnoFieldName(annoFieldName); fmap.setColumnName(colName); fmap.setSize(colSize); fmap.setSqlType(dataType); mapInfo.getMapField().put(colName, fmap); break; } } } } } } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { } } } } }); // don't map this annotation if no fields match columns if (mapInfo.getMapField().size() == 0 && mapInfo.getCoveredTextColumn() == null && Strings.isNullOrEmpty(mapInfo.getUimaTypeIdColumnName())) return null; // generate sql StringBuilder b = new StringBuilder("insert into "); b.append(this.getTablePrefix()).append(mapInfo.getTableName()); b.append("(anno_base_id"); // add coveredText column if available if (mapInfo.getCoveredTextColumn() != null) { b.append(", coveredText"); } // add uima_type_id column if available if (mapInfo.getUimaTypeIdColumnName() != null) { b.append(", uima_type_id"); } // add other fields for (Map.Entry<String, ColumnMappingInfo> fieldEntry : mapInfo.getMapField().entrySet()) { b.append(", ").append(dialect.openQuote()).append(fieldEntry.getValue().getColumnName()) .append(dialect.closeQuote()); } b.append(") values (?"); // add coveredText bind param if (mapInfo.getCoveredTextColumn() != null) { b.append(", ?"); } // add uimaTypeId bind param if (mapInfo.getUimaTypeIdColumnName() != null) { b.append(", ?"); } // add bind params for other fields b.append(Strings.repeat(", ?", mapInfo.getMapField().size())).append(")"); mapInfo.setSql(b.toString()); if (log.isInfoEnabled()) log.info("sql insert for type " + type.getName() + ": " + mapInfo.getSql()); if (log.isDebugEnabled()) log.debug("initMapInfo(" + annoName + "): " + mapInfo); return mapInfo; }
From source file:org.jumpmind.symmetric.db.AbstractSymmetricDialect.java
public int getSqlTypeForIds() { return Types.NUMERIC; }
From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java
public static boolean isPrimitiveType(int colType) { switch (colType) { case Types.BIT: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.REAL: case Types.FLOAT: case Types.DOUBLE: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return true; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.NUMERIC: case Types.DECIMAL: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return false; default:/*from w ww.j a v a2s. co m*/ return false; } }
From source file:mondrian.spi.impl.JdbcDialectImpl.java
public SqlStatement.Type getType(ResultSetMetaData metaData, int columnIndex) throws SQLException { final int columnType = metaData.getColumnType(columnIndex + 1); SqlStatement.Type internalType = null; if (columnType != Types.NUMERIC && columnType != Types.DECIMAL) { internalType = DEFAULT_TYPE_MAP.get(columnType); } else {/* ww w .j av a 2 s . co m*/ final int precision = metaData.getPrecision(columnIndex + 1); final int scale = metaData.getScale(columnIndex + 1); if (scale == 0 && precision <= 9) { // An int (up to 2^31 = 2.1B) can hold any NUMBER(10, 0) value // (up to 10^9 = 1B). internalType = SqlStatement.Type.INT; } else { internalType = SqlStatement.Type.DOUBLE; } } internalType = internalType == null ? SqlStatement.Type.OBJECT : internalType; logTypeInfo(metaData, columnIndex, internalType); return internalType; }