List of usage examples for java.sql Types BIGINT
int BIGINT
To view the source code for java.sql Types BIGINT.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BIGINT
.
From source file:Main.java
/** * Gets the name of the type to be used with the internal dbms * /*from w w w .jav a 2s . co m*/ * @param type * java.sql.Types constant * * @return String * * @throws RuntimeException * If the Type is not recognized */ public static String getTypeString(int type) { switch (type) { case Types.BIGINT: return "BIGINT"; case Types.BIT: case Types.BOOLEAN: return "BOOLEAN"; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return "VARCHAR"; case Types.DATE: return "DATE"; case Types.DECIMAL: case Types.NUMERIC: case Types.FLOAT: case Types.DOUBLE: case Types.REAL: return "DOUBLE"; case Types.INTEGER: return "INTEGER"; case Types.SMALLINT: return "SHORT"; case Types.TINYINT: return "BYTE"; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return "BINARY"; case Types.TIMESTAMP: return "TIMESTAMP"; case Types.TIME: return "TIME"; default: throw new RuntimeException("Cannot edit the type: " + type); } }
From source file:com.espertech.esperio.db.core.DBUtil.java
/** * Returns the object value for a given column and type. * @param rs result set/*from w ww . ja v a2 s . c o m*/ * @param index column index * @param valueType value type * @return object value * @throws java.sql.SQLException if the column could not be read */ public static Object getValue(ResultSet rs, int index, int valueType) throws SQLException { if (valueType == Types.INTEGER) { return rs.getInt(index); } else if (valueType == Types.BIGINT) { return rs.getLong(index); } else if (valueType == Types.BLOB) { Blob blob = rs.getBlob(index); return getBlobValue(blob); } return rs.getObject(index); }
From source file:com.mirth.connect.donkey.model.channel.MetaDataColumnType.java
public static MetaDataColumnType fromSqlType(int sqlType) { switch (sqlType) { case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.CLOB: case Types.NCLOB: return STRING; case Types.BIGINT: case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.NUMERIC: case Types.REAL: return NUMBER; case Types.BOOLEAN: case Types.BIT: case Types.CHAR: return BOOLEAN; case Types.TIMESTAMP: case Types.TIME: case Types.DATE: return TIMESTAMP; }/*ww w . j a v a2 s . c o m*/ return null; }
From source file:Main.java
public static String getCloverTypeFromJdbcType(int jdbcDataType) { switch (jdbcDataType) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return "date"; case Types.ARRAY: case Types.BINARY: case Types.DATALINK: case Types.BLOB: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.NULL: case Types.OTHER: case Types.REF: case Types.STRUCT: case Types.VARBINARY: case Types.LONGVARBINARY: System.out.println("Outputting cbyte for Type: " + jdbcDataType); return "cbyte"; case Types.BIT: case Types.BOOLEAN: return "boolean"; case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.NUMERIC: case Types.REAL: return "numeric"; case Types.INTEGER: case Types.SMALLINT: return "integer"; case Types.BIGINT: return "long"; case Types.CHAR: case Types.VARCHAR: case Types.CLOB: case Types.LONGVARCHAR: return "string"; }/*w w w . ja v a2s.co m*/ System.out.println("Outputting string for unknown Type: " + jdbcDataType); return "string"; }
From source file:com.cloudera.sqoop.hive.HiveTypes.java
/** * Given JDBC SQL types coming from another database, what is the best * mapping to a Hive-specific type?/*ww w. j av a2 s . co m*/ */ public static String toHiveType(int sqlType) { if (sqlType == Types.INTEGER) { return "INT"; } else if (sqlType == Types.VARCHAR) { return "STRING"; } else if (sqlType == Types.CHAR) { return "STRING"; } else if (sqlType == Types.LONGVARCHAR) { return "STRING"; } else if (sqlType == Types.NUMERIC) { // Per suggestion on hive-user, this is converted to DOUBLE for now. return "DOUBLE"; } else if (sqlType == Types.DECIMAL) { // Per suggestion on hive-user, this is converted to DOUBLE for now. return "DOUBLE"; } else if (sqlType == Types.BIT) { return "BOOLEAN"; } else if (sqlType == Types.BOOLEAN) { return "BOOLEAN"; } else if (sqlType == Types.TINYINT) { return "TINYINT"; } else if (sqlType == Types.SMALLINT) { return "INT"; } else if (sqlType == Types.BIGINT) { return "BIGINT"; } else if (sqlType == Types.REAL) { return "DOUBLE"; } else if (sqlType == Types.FLOAT) { return "DOUBLE"; } else if (sqlType == Types.DOUBLE) { return "DOUBLE"; } else if (sqlType == Types.DATE) { // unfortunate type coercion return "STRING"; } else if (sqlType == Types.TIME) { // unfortunate type coercion return "STRING"; } else if (sqlType == Types.TIMESTAMP) { // unfortunate type coercion return "STRING"; } else if (sqlType == Types.CLOB) { return "STRING"; } else { // TODO(aaron): Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, // BLOB, ARRAY, STRUCT, REF, JAVA_OBJECT. return null; } }
From source file:com.nabla.wapp.server.json.SqlColumn.java
public SqlColumn(String label, int type, int length) { this.label = label; this.type = (type == Types.TINYINT) ? (length == 1 ? Types.BOOLEAN : type) : type; if (log.isDebugEnabled()) { String s;//from w w w . j a v a2 s .c o m switch (this.type) { case Types.BIGINT: case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: s = "INTEGER"; break; case Types.BOOLEAN: case Types.BIT: s = "BOOLEAN"; break; case Types.DATE: s = "DATE"; break; case Types.TIMESTAMP: s = "TIMESTAMP"; break; case Types.DOUBLE: s = "DOUBLE"; break; case Types.FLOAT: s = "FLOAT"; break; case Types.NULL: s = "NULL"; break; default: s = "STRING"; break; } log.debug("column '" + this.label + "' " + s); } }
From source file:com.espertech.esper.util.TestSQLTypeMapUtil.java
public void testMapping() { Map<Integer, Class> testData = new HashMap<Integer, Class>(); testData.put(Types.CHAR, String.class); testData.put(Types.VARCHAR, String.class); testData.put(Types.LONGVARCHAR, String.class); testData.put(Types.NUMERIC, BigDecimal.class); testData.put(Types.DECIMAL, BigDecimal.class); testData.put(Types.BIT, Boolean.class); testData.put(Types.BOOLEAN, Boolean.class); testData.put(Types.TINYINT, Byte.class); testData.put(Types.SMALLINT, Short.class); testData.put(Types.INTEGER, Integer.class); testData.put(Types.BIGINT, Long.class); testData.put(Types.REAL, Float.class); testData.put(Types.FLOAT, Double.class); testData.put(Types.DOUBLE, Double.class); testData.put(Types.BINARY, byte[].class); testData.put(Types.VARBINARY, byte[].class); testData.put(Types.LONGVARBINARY, byte[].class); testData.put(Types.DATE, java.sql.Date.class); testData.put(Types.TIMESTAMP, java.sql.Timestamp.class); testData.put(Types.TIME, java.sql.Time.class); testData.put(Types.CLOB, java.sql.Clob.class); testData.put(Types.BLOB, java.sql.Blob.class); testData.put(Types.ARRAY, java.sql.Array.class); testData.put(Types.STRUCT, java.sql.Struct.class); testData.put(Types.REF, java.sql.Ref.class); testData.put(Types.DATALINK, java.net.URL.class); for (int type : testData.keySet()) { Class result = SQLTypeMapUtil.sqlTypeToClass(type, null); log.debug(".testMapping Mapping " + type + " to " + result.getSimpleName()); assertEquals(testData.get(type), result); }//from w w w . ja va 2 s. c o m assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.JAVA_OBJECT, "java.lang.String")); assertEquals(String.class, SQLTypeMapUtil.sqlTypeToClass(Types.DISTINCT, "java.lang.String")); }
From source file:at.alladin.rmbt.db.fields.LongField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.BIGINT); else//from www .j ava2 s. c om ps.setLong(idx, value); }
From source file:com.streamsets.pipeline.stage.it.AllNullTypesIT.java
@Parameterized.Parameters(name = "type({0})") public static Collection<Object[]> data() throws Exception { return Arrays.asList(new Object[][] { { Field.create(Field.Type.BOOLEAN, null), true, Types.BOOLEAN }, { Field.create(Field.Type.CHAR, null), true, Types.VARCHAR }, { Field.create(Field.Type.BYTE, null), false, 0 }, { Field.create(Field.Type.SHORT, null), true, Types.INTEGER }, { Field.create(Field.Type.INTEGER, null), true, Types.INTEGER }, { Field.create(Field.Type.LONG, null), true, Types.BIGINT }, { Field.create(Field.Type.FLOAT, null), true, Types.FLOAT }, { Field.create(Field.Type.DOUBLE, null), true, Types.DOUBLE }, { Field.create(Field.Type.DATE, null), true, Types.DATE }, { Field.create(Field.Type.DATETIME, null), true, Types.VARCHAR }, { Field.create(Field.Type.TIME, null), true, Types.VARCHAR }, { Field.create(Field.Type.DECIMAL, null), true, Types.DECIMAL }, { Field.create(Field.Type.STRING, null), true, Types.VARCHAR }, { Field.create(Field.Type.BYTE_ARRAY, null), true, Types.BINARY }, { Field.create(Field.Type.MAP, null), false, 0 }, { Field.create(Field.Type.LIST, null), false, 0 }, { Field.create(Field.Type.LIST_MAP, null), false, 0 }, }); }
From source file:RowSetModel.java
public Class getColumnClass(int column) { String cname;//ww w .j a v a2 s. co m 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); } }