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:net.sourceforge.vulcan.spring.jdbc.DependencyQuery.java
public DependencyQuery(DataSource dataSource) { super(dataSource, "select name, uuid " + "from builds " + "inner join project_names on builds.project_id = project_names.id " + "inner join build_dependencies on builds.id = build_dependencies.dependency_build_id " + "where build_dependencies.build_id = ?"); declareParameter(new SqlParameter("build_dependencies.build_id", Types.NUMERIC)); compile();//from w ww.jav a2s . c o m }
From source file:net.sourceforge.vulcan.spring.jdbc.ChangeSetQuery.java
public ChangeSetQuery(DataSource dataSource) { super(dataSource, "select message, author, author_email, commit_timestamp, revision_label, build_id, change_set_id " + "from change_sets where build_id = ? order by commit_timestamp"); declareParameter(new SqlParameter("build_id", Types.NUMERIC)); compile();/*from w w w.j a v a 2 s . com*/ modifiedPathQuery = new ModifiedPathQuery(dataSource); }
From source file:org.plasma.sdo.jdbc.service.StoredProcSequenceGenerator.java
private Long getSeqNum(String seqName) { CallableStatement cstmt1 = null; try {/*from w ww. jav a 2 s .com*/ if (conn == null) initialize(); cstmt1 = (CallableStatement) conn.prepareCall("{ call GET_SQNC_NMBR (?, ?) }"); cstmt1.registerOutParameter(2, Types.NUMERIC); cstmt1.setString(1, seqName); cstmt1.execute(); long id = cstmt1.getLong(2); return new Long(id); } catch (Throwable t) { throw new RuntimeException(t); } finally { if (cstmt1 != null) try { cstmt1.close(); } catch (Throwable t2) { } } }
From source file:com.trackplus.ddl.GenericStringValueConverter.java
protected String extractColumnValue(ResultSet resultSet, int columnIdx, int jdbcType) throws SQLException, DDLException { String value = resultSet.getString(columnIdx); if (value != null) { switch (jdbcType) { case Types.NUMERIC: case Types.DECIMAL: break; case Types.BIT: case Types.BOOLEAN: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.REAL: case Types.FLOAT: case Types.DOUBLE: { break; }//w w w . java 2 s. c o m case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.BINARY: case Types.VARBINARY: case Types.TIME: case Types.CLOB: case Types.ARRAY: case Types.REF: { value = "'" + value.replaceAll("'", "''") + "'"; break; } case Types.DATE: case Types.TIMESTAMP: { Date d = resultSet.getDate(columnIdx); Calendar cal = Calendar.getInstance(); cal.setTime(d); int year = cal.get(Calendar.YEAR); if (year < 1900) { throw new DDLException("Invalid date:" + d); } else { value = "'" + value + "'"; } break; } case Types.BLOB: case Types.LONGVARBINARY: { Blob blobValue = resultSet.getBlob(columnIdx); String str = new String(Base64.encodeBase64(blobValue.getBytes(1l, (int) blobValue.length()))); value = "'" + str + "'"; break; } default: break; } } return value; }
From source file:RowSetModel.java
public Class getColumnClass(int column) { String cname;/*www . ja v a 2 s .c om*/ int type; try { ResultSetMetaData meta = rowSet.getMetaData(); if (meta == null) { return null; } type = meta.getColumnType(column + 1); } catch (SQLException e) { e.printStackTrace(); return super.getColumnClass(column); } switch (type) { case Types.BIT: { cname = "java.lang.Boolean"; break; } case Types.TINYINT: { cname = "java.lang.Byte"; break; } case Types.SMALLINT: { cname = "java.lang.Short"; break; } case Types.INTEGER: { cname = "java.lang.Integer"; break; } case Types.BIGINT: { cname = "java.lang.Long"; break; } case Types.FLOAT: case Types.REAL: { cname = "java.lang.Float"; break; } case Types.DOUBLE: { cname = "java.lang.Double"; break; } case Types.NUMERIC: { cname = "java.lang.Number"; break; } case Types.DECIMAL: { cname = "java.math.BigDecimal"; break; } case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: { cname = "java.lang.String"; break; } case Types.DATE: { cname = "java.sql.Date"; break; } case Types.TIME: { cname = "java.sql.Time"; break; } case Types.TIMESTAMP: { cname = "java.sql.Timestamp"; break; } case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: { cname = "byte[]"; break; } case Types.OTHER: case Types.JAVA_OBJECT: { cname = "java.lang.Object"; break; } case Types.CLOB: { cname = "java.sql.Clob"; break; } case Types.BLOB: { cname = "java.ssql.Blob"; break; } case Types.REF: { cname = "java.sql.Ref"; break; } case Types.STRUCT: { cname = "java.sql.Struct"; break; } default: { return super.getColumnClass(column); } } try { return Class.forName(cname); } catch (Exception e) { e.printStackTrace(); return super.getColumnClass(column); } }
From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java
private static Class mapSQLType(final int t) { switch (t) {//from ww w .ja va 2 s . c o m case Types.ARRAY: return Object[].class; case Types.BIGINT: return Long.class; case Types.BINARY: return byteArrayClass; case Types.BIT: return Boolean.class; case Types.BLOB: return Blob.class; case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2 return Boolean.class; case Types.CHAR: return String.class; case Types.CLOB: return Clob.class; case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2 return URL.class; case Types.DATE: return java.sql.Date.class; case Types.DECIMAL: return java.math.BigDecimal.class; case Types.DISTINCT: return Object.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: return Double.class; case Types.INTEGER: return Integer.class; case Types.JAVA_OBJECT: return Object.class; case Types.LONGVARBINARY: return byteArrayClass; case Types.LONGVARCHAR: return String.class; case Types.NCLOB: return NClob.class; case Types.NULL: return Object.class; case Types.NUMERIC: return java.math.BigDecimal.class; case Types.NCHAR: case Types.NVARCHAR: case Types.LONGNVARCHAR: return String.class; case Types.OTHER: return Object.class; case Types.REAL: return Float.class; case Types.REF: return Ref.class; case Types.ROWID: return RowId.class; case Types.SMALLINT: return Short.class; case Types.STRUCT: return Struct.class; case Types.SQLXML: return SQLXML.class; case Types.TIME: return Time.class; case Types.TIMESTAMP: return Timestamp.class; case Types.TINYINT: return Byte.class; case Types.VARBINARY: return byteArrayClass; case Types.VARCHAR: return String.class; default: return Object.class; } }
From source file:com.redsqirl.workflow.utils.jdbc.GenericConfFile.java
public GenericConfFile(String name, Connection conn) throws SQLException { dictionaryName = name;// w w w . j a v a2 s . c o m databaseMetaData = conn.getMetaData(); typeRecognized = new LinkedHashMap<Integer, FieldType>(); typeRecognized.put(Types.BOOLEAN, FieldType.BOOLEAN); typeRecognized.put(Types.DATE, FieldType.DATETIME); typeRecognized.put(Types.TIME, FieldType.DATETIME); typeRecognized.put(Types.DOUBLE, FieldType.DOUBLE); typeRecognized.put(Types.NUMERIC, FieldType.DOUBLE); typeRecognized.put(Types.DECIMAL, FieldType.DOUBLE); typeRecognized.put(Types.REAL, FieldType.DOUBLE); typeRecognized.put(Types.FLOAT, FieldType.FLOAT); typeRecognized.put(Types.INTEGER, FieldType.INT); typeRecognized.put(Types.SMALLINT, FieldType.INT); typeRecognized.put(Types.TINYINT, FieldType.INT); typeRecognized.put(Types.BIGINT, FieldType.LONG); typeRecognized.put(Types.VARCHAR, FieldType.STRING); typeRecognized.put(Types.CHAR, FieldType.STRING); typeRecognized.put(Types.LONGVARCHAR, FieldType.STRING); typeRecognized.put(Types.NVARCHAR, FieldType.STRING); typeRecognized.put(Types.NCHAR, FieldType.STRING); typeRecognized.put(Types.LONGNVARCHAR, FieldType.STRING); typeRecognized.put(Types.TIMESTAMP, FieldType.TIMESTAMP); }
From source file:com.thinkbiganalytics.discovery.util.ParserHelper.java
public static String sqlTypeToHiveType(Integer type) { switch (type) { case Types.BIGINT: return "bigint"; case Types.NUMERIC: case Types.DOUBLE: case Types.DECIMAL: return "double"; case Types.INTEGER: return "int"; case Types.FLOAT: return "float"; case Types.TINYINT: return "tinyint"; case Types.DATE: return "date"; case Types.TIMESTAMP: return "timestamp"; case Types.BOOLEAN: return "boolean"; case Types.BINARY: return "binary"; default://from w w w . j a v a 2 s . c om return "string"; } }
From source file:com.cloudera.sqoop.hive.HiveTypes.java
/** * @return true if a sql type can't be translated to a precise match * in Hive, and we have to cast it to something more generic. *//*ww w . ja v a 2 s. c om*/ public static boolean isHiveTypeImprovised(int sqlType) { return sqlType == Types.DATE || sqlType == Types.TIME || sqlType == Types.TIMESTAMP || sqlType == Types.DECIMAL || sqlType == Types.NUMERIC; }
From source file:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the SQL type name for the given {@link Types} constant. *//*from w ww . j av a 2s . co m*/ public static String getJDBCName(int type) { switch (type) { case Types.ARRAY: return "array"; case Types.BIGINT: return "bigint"; case Types.BINARY: return "binary"; case Types.BIT: return "bit"; case Types.BLOB: return "blob"; case Types.CHAR: return "char"; case Types.CLOB: return "clob"; case Types.DATE: return "date"; case Types.DECIMAL: return "decimal"; case Types.DISTINCT: return "distinct"; case Types.DOUBLE: return "double"; case Types.FLOAT: return "float"; case Types.INTEGER: return "integer"; case Types.JAVA_OBJECT: return "java_object"; case Types.LONGVARBINARY: return "longvarbinary"; case Types.LONGVARCHAR: return "longvarchar"; case Types.NULL: return "null"; case Types.NUMERIC: return "numeric"; case Types.OTHER: return "other"; case Types.REAL: return "real"; case Types.REF: return "ref"; case Types.SMALLINT: return "smallint"; case Types.STRUCT: return "struct"; case Types.TIME: return "time"; case Types.TIMESTAMP: return "timestamp"; case Types.TINYINT: return "tinyint"; case Types.VARBINARY: return "varbinary"; case Types.VARCHAR: return "varchar"; default: return "unknown(" + type + ")"; } }