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:com.streamsets.pipeline.stage.it.AllPartitionTypesIT.java
@Parameterized.Parameters(name = "type({0})") public static Collection<Object[]> data() throws Exception { return Arrays.asList(new Object[][] { // Supported types { Field.create(Field.Type.INTEGER, 1), partition(HiveType.INT), true, Types.INTEGER, 1 }, { Field.create(Field.Type.LONG, 1), partition(HiveType.BIGINT), true, Types.BIGINT, 1L }, { Field.create(Field.Type.STRING, "value"), partition(HiveType.STRING), true, Types.VARCHAR, "value" }, // Unsupported types { Field.create(Field.Type.BOOLEAN, true), partition(HiveType.BOOLEAN), false, 0, null }, { Field.create(Field.Type.DATE, new Date()), partition(HiveType.DATE), false, 0, null }, { Field.create(Field.Type.FLOAT, 1.2), partition(HiveType.FLOAT), false, 0, null }, { Field.create(Field.Type.DOUBLE, 1.2), partition(HiveType.DOUBLE), false, 0, null }, { Field.create(Field.Type.BYTE_ARRAY, new byte[] { 0x00 }), partition(HiveType.BINARY), false, 0, null },//from www . j av a 2 s . co m // Decimal fails with java.lang.ArrayIndexOutOfBoundsException // {Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), partition(HiveType.DECIMAL), false, 0, null}, }); }
From source file:org.gridobservatory.greencomputing.dao.TimeseriesDao.java
public BigInteger insert(T timeseriesType) { KeyHolder keyHolder = new GeneratedKeyHolder(); PreparedStatementCreatorFactory preparedStatementCreatorFactory = new PreparedStatementCreatorFactory( "insert into time_series (constant_value,start_date,end_date,acquisition_count ) " + "values (?, ?, ?, ?)", new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT }); PreparedStatementCreator newPreparedStatementCreator = preparedStatementCreatorFactory .newPreparedStatementCreator(new Object[] { timeseriesType.getConstantValue() != null ? timeseriesType.getConstantValue().getValue() : "", new Date(timeseriesType.getStartDate().longValue() * 1000), new Date(timeseriesType.getEndDate().longValue() * 1000), timeseriesType.getAcquisitionCount() }); preparedStatementCreatorFactory.setReturnGeneratedKeys(true); this.getJdbcTemplate().update(newPreparedStatementCreator, keyHolder); BigInteger timeSeriesId = BigInteger.valueOf(keyHolder.getKey().longValue()); insertTimeSeriesAcquisitions(timeSeriesId, timeseriesType.getA()); return timeSeriesId; }
From source file:dao.DirBlobTitleQuery.java
/** * For each row in the result set, the mapRow method is called by * Spring. In the very first call to mapRow() for the first row in the result * set, we make a call to RSMD to get columnNames and cache * them to a local array in this object. This way, we can avoid multiple calls * to RSMD since, spring calls mapRow many times (one per row in result set). * *//*from w ww. j av a2s . c o m*/ DirBlobTitleQuery(DataSource ds) { super(ds, "select 1 from dirblob where directoryid=? and btitle=?"); declareParameter(new SqlParameter("directoryid", Types.BIGINT)); declareParameter(new SqlParameter("btitle", Types.VARCHAR)); compile(); }
From source file:com.bigdata.etl.util.DwUtil.java
public static void bulkInsert(String tableName, List<Map<String, String>> lst) { ResultSet rs = null;//from ww w.j ava 2 s. c o m java.sql.Statement stmt = null; try (java.sql.Connection conn = DataSource.getConnection()) { stmt = conn.createStatement(); rs = stmt.executeQuery("select top 0 * from " + tableName); try (SQLServerBulkCopy bulk = new SQLServerBulkCopy(url + "user=" + user + ";password=" + password)) { SQLServerBulkCopyOptions sqlsbc = new SQLServerBulkCopyOptions(); sqlsbc.setBulkCopyTimeout(60 * 60 * 1000); bulk.setBulkCopyOptions(sqlsbc); bulk.setDestinationTableName(tableName); ResultSetMetaData rsmd = rs.getMetaData(); if (lst == null) { return; } // System.out.println(LocalTime.now() + " "+Thread.currentThread().getId()+" "+lst.size()); try (CachedRowSetImpl x = new CachedRowSetImpl()) { x.populate(rs); for (int k = 0; k < lst.size(); k++) { Map<String, String> map = lst.get(k); x.last(); x.moveToInsertRow(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { String name = rsmd.getColumnName(i).toUpperCase(); int type = rsmd.getColumnType(i);//package java.sql.Type? try { switch (type) { case Types.VARCHAR: case Types.NVARCHAR: int len = rsmd.getColumnDisplaySize(i); String v = map.get(name); if (map.containsKey(name)) { x.updateString(i, v.length() > len ? v.substring(0, len) : v); } else { x.updateNull(i); } break; case Types.BIGINT: if (map.containsKey(name) && map.get(name).matches("\\d{1,}")) { x.updateLong(i, Long.valueOf(map.get(name))); } else { // x.updateLong(i, 0); x.updateNull(i); } break; case Types.FLOAT: if (map.containsKey(name) && map.get(name).matches("([+-]?)\\d*\\.\\d+$")) { x.updateFloat(i, Float.valueOf(map.get(name))); } else { x.updateNull(i); } break; case Types.DOUBLE: if (map.containsKey(name) && map.get(name).trim().length() > 0 && StringUtils.isNumeric(map.get(name))) { x.updateDouble(i, Double.valueOf(map.get(name))); } else { x.updateNull(i); } break; case Types.INTEGER: if (map.containsKey(name) && map.get(name).matches("\\d{1,}")) { x.updateInt(i, Integer.valueOf(map.get(name))); } else { x.updateNull(i); } break; default: throw new RuntimeException("? " + type); } /* if(map.containsKey("SYS_TELECOM")) System.err.println(map.get("SYS_TELECOM")); */ } catch (RuntimeException | SQLException e) { Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, "? name=" + name + " v=" + map.get(name), e); } } x.insertRow(); x.moveToCurrentRow(); //x.acceptChanges(); } long start = System.currentTimeMillis(); bulk.writeToServer(x); long end = System.currentTimeMillis(); System.out.println(LocalTime.now() + " " + Thread.currentThread().getId() + " " + (end - start) + "ms" + " " + x.size()); } } } catch (SQLException e) { Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, null, e); } finally { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } } catch (SQLException ex) { Logger.getLogger(DwUtil.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.streamsets.pipeline.stage.it.AllSdcTypesIT.java
@Parameterized.Parameters(name = "type({0})") public static Collection<Object[]> data() throws Exception { return Arrays.asList(new Object[][] { { Field.create(Field.Type.BOOLEAN, true), true, Types.BOOLEAN, true }, { Field.create(Field.Type.CHAR, 'A'), true, Types.VARCHAR, "A" }, { Field.create(Field.Type.BYTE, (byte) 0x00), false, 0, null }, { Field.create(Field.Type.SHORT, 10), true, Types.INTEGER, 10 }, { Field.create(Field.Type.INTEGER, 10), true, Types.INTEGER, 10 }, { Field.create(Field.Type.LONG, 10), true, Types.BIGINT, 10L }, { Field.create(Field.Type.FLOAT, 1.5), true, Types.FLOAT, 1.5 }, { Field.create(Field.Type.DOUBLE, 1.5), true, Types.DOUBLE, 1.5 }, { Field.create(Field.Type.DATE, new Date(116, 5, 13)), true, Types.DATE, new Date(116, 5, 13) }, { Field.create(Field.Type.DATETIME, date), true, Types.VARCHAR, datetimeFormat.format(date) }, { Field.create(Field.Type.TIME, date), true, Types.VARCHAR, timeFormat.format(date) }, { Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), true, Types.DECIMAL, new BigDecimal(BigInteger.valueOf(15), 1, new MathContext(2, RoundingMode.FLOOR)) }, { Field.create(Field.Type.STRING, "StreamSets"), true, Types.VARCHAR, "StreamSets" }, { Field.create(Field.Type.BYTE_ARRAY, new byte[] { (byte) 0x00 }), true, Types.BINARY, new byte[] { (byte) 0x00 } }, { Field.create(Field.Type.MAP, Collections.emptyMap()), false, 0, null }, { Field.create(Field.Type.LIST, Collections.emptyList()), false, 0, null }, { Field.create(Field.Type.LIST_MAP, new LinkedHashMap<>()), false, 0, null }, }); }
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; }//from ww w . j a v a 2s . co 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: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:// ww w . j a v a2 s . co m return "string"; } }
From source file:uk.co.blackpepper.support.spring.jdbc.jooq.SpringJdbcJooqUtilsTest.java
@Test public void getSqlTypesWithParamsReturnsSqlTypes() { List<? extends Param<?>> fields = asList(param("x", String.class), param("y", Long.class)); int[] actual = SpringJdbcJooqUtils.getSqlTypes(fields); assertThat(actual, is(new int[] { Types.VARCHAR, Types.BIGINT })); }
From source file:dao.DirMemberAuthorQuery.java
/** * This constructor is called when the collabrum messages method makes a * call to query.execute(). After the query is executed, the result set is * returned. For each row in the result set, the mapRow method is called by * Spring. In the very first call to mapRow() for the first row in the result * set, we make a call to RSMD to get columnNames and cache * them to a local array in this object. This way, we can avoid multiple calls * to RSMD since, spring calls mapRow many times (one per row in result set). * */// www.j a va 2s . co m // dont use collmsgattr.rid as it may have null values and clash with rid of collmessages. DirMemberAuthorQuery(DataSource ds) { super(ds, "select c1.entryid from diradmin c1, diradmin c2 " + "where c1.directoryid=c2.directoryid and c1.ownerid=? " + "and c2.ownerid=? limit 1"); declareParameter(new SqlParameter("ownerid", Types.BIGINT)); declareParameter(new SqlParameter("ownerid", Types.BIGINT)); compile(); }
From source file:com.nabla.wapp.server.json.SqlColumn.java
public void write(final ResultSet rs, int column, final JSONObject record) throws SQLException { switch (type) { case Types.BIGINT: case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: record.put(label, rs.getInt(column)); break;//from www . j a v a2 s. c o m case Types.BOOLEAN: case Types.BIT: record.put(label, rs.getBoolean(column)); break; case Types.DATE: final Date dt = rs.getDate(column); if (rs.wasNull()) record.put(label, null); else record.put(label, new JSonDate(dt)); return; case Types.TIMESTAMP: final Timestamp tm = rs.getTimestamp(column); if (rs.wasNull()) record.put(label, null); else record.put(label, timeStampFormat.format(tm)); return; case Types.DOUBLE: record.put(label, rs.getDouble(column)); break; case Types.FLOAT: record.put(label, rs.getFloat(column)); break; case Types.NULL: record.put(label, null); return; default: record.put(label, rs.getString(column)); break; } if (rs.wasNull()) record.put(label, null); }