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:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseClusterTable.java
public long nextConfigurationFileIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) { final String S_ProcName = "nextConfigurationFileIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/*from w ww . j a v a 2 s .c om*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextConfigurationFileIdGen = null; try { String sql = "{ call sp_next_configurationfileidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextConfigurationFileIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextConfigurationFileIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextConfigurationFileIdGen.setLong(argIdx++, Id); stmtSelectNextConfigurationFileIdGen.execute(); long nextId = stmtSelectNextConfigurationFileIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextConfigurationFileIdGen != null) { try { stmtSelectNextConfigurationFileIdGen.close(); } catch (SQLException e) { } stmtSelectNextConfigurationFileIdGen = null; } } }
From source file:ch.rgw.tools.JdbcLink.java
public static int generalType(int t) { switch (t) {//from www. ja va2s. co m case Types.BIGINT: case Types.BIT: case Types.BOOLEAN: case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: return INTEGRAL; case Types.VARCHAR: case Types.CHAR: case Types.LONGVARCHAR: return TEXT; case Types.BINARY: case Types.BLOB: case Types.CLOB: case Types.LONGVARBINARY: case Types.VARBINARY: return BINARY; default: return OTHER; } }
From source file:com.nextep.designer.dbgm.services.impl.DerbyStorageService.java
public IDatatype getColumnDatatype(IDataSet set, IBasicColumn c) { final int jdbcType = getColumnSqlType(set, c); final IDatatype type = c.getDatatype(); IDatatype derbyType = null;/*from w ww.j a va 2s . c om*/ switch (jdbcType) { case Types.DOUBLE: derbyType = new Datatype("DOUBLE"); //$NON-NLS-1$ break; case Types.BIGINT: derbyType = new Datatype("BIGINT"); //$NON-NLS-1$ break; case Types.TIMESTAMP: derbyType = new Datatype("TIMESTAMP"); //$NON-NLS-1$ break; default: derbyType = new Datatype("VARCHAR"); //$NON-NLS-1$ if (type.getLength() > 0) { if (type.getLength() > MAX_DERBY_VARCHAR_LENGTH) { LOGGER.warn("Dataset datatype for VARCHAR column " + c.getName() + " has been truncated to " + MAX_DERBY_VARCHAR_LENGTH); } derbyType.setLength(Math.min(type.getLength(), MAX_DERBY_VARCHAR_LENGTH)); } else { derbyType.setLength(4000); } break; } return derbyType; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public long nextConfigurationFileIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextConfigurationFileIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }/*from w w w.j a v a 2s . c om*/ Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextConfigurationFileIdGen = null; try { String sql = "{ call sp_next_configurationfileidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextConfigurationFileIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextConfigurationFileIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT); stmtSelectNextConfigurationFileIdGen.setLong(argIdx++, Id); stmtSelectNextConfigurationFileIdGen.execute(); long nextId = stmtSelectNextConfigurationFileIdGen.getLong(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextConfigurationFileIdGen != null) { try { stmtSelectNextConfigurationFileIdGen.close(); } catch (SQLException e) { } stmtSelectNextConfigurationFileIdGen = null; } } }
From source file:com.nextep.designer.dbgm.services.impl.DerbyStorageService.java
@Override public int getColumnSqlType(IDataSet set, IBasicColumn c) { final DBVendor vendor = DBGMHelper.getVendorFor(set); final IDatatypeProvider datatypeProvider = DBGMHelper.getDatatypeProvider(vendor); final IDatatype type = c.getDatatype(); int jdbcType; // Analyzing type final String typeName = type.getName().toUpperCase(); if (datatypeProvider.getNumericDatatypes().contains(typeName)) { if (datatypeProvider.isDecimalDatatype(type)) { jdbcType = Types.DOUBLE; } else {/*www . ja v a 2 s . c o m*/ jdbcType = Types.BIGINT; } } else if (datatypeProvider.getDateDatatypes().contains(typeName)) { jdbcType = Types.TIMESTAMP; } else { jdbcType = Types.VARCHAR; } return jdbcType; }
From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java
public static String generateNextPartitionOffset(TableContext tableContext, String column, String offset) { final String partitionSize = tableContext.getOffsetColumnToPartitionOffsetAdjustments().get(column); switch (tableContext.getOffsetColumnToType().get(column)) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: final int int1 = Integer.parseInt(offset); final int int2 = Integer.parseInt(partitionSize); return String.valueOf(int1 + int2); case Types.TIMESTAMP: final Timestamp timestamp1 = getTimestampForOffsetValue(offset); final long timestampAdj = Long.parseLong(partitionSize); final Timestamp timestamp2 = Timestamp.from(timestamp1.toInstant().plusMillis(timestampAdj)); return getOffsetValueForTimestamp(timestamp2); case Types.BIGINT: // TIME, DATE are represented as long (epoch) case Types.TIME: case Types.DATE: final long long1 = Long.parseLong(offset); final long long2 = Long.parseLong(partitionSize); return String.valueOf(long1 + long2); case Types.FLOAT: case Types.REAL: final float float1 = Float.parseFloat(offset); final float float2 = Float.parseFloat(partitionSize); return String.valueOf(float1 + float2); case Types.DOUBLE: final double double1 = Double.parseDouble(offset); final double double2 = Double.parseDouble(partitionSize); return String.valueOf(double1 + double2); case Types.NUMERIC: case Types.DECIMAL: final BigDecimal decimal1 = new BigDecimal(offset); final BigDecimal decimal2 = new BigDecimal(partitionSize); return decimal1.add(decimal2).toString(); }/*from w ww . j a va 2 s. c o m*/ return null; }
From source file:org.waarp.common.database.data.AbstractDbData.java
/** * Create the equivalent object in Json (no database access) * /*www . j a v a 2s . c o m*/ * @return The ObjectNode Json equivalent */ public ObjectNode getJson() { ObjectNode node = JsonHandler.createObjectNode(); node.put(JSON_MODEL, this.getClass().getSimpleName()); for (DbValue value : allFields) { if (value.column.equalsIgnoreCase("UPDATEDINFO")) { continue; } switch (value.type) { case Types.VARCHAR: case Types.LONGVARCHAR: node.put(value.column, (String) value.value); break; case Types.BIT: node.put(value.column, (Boolean) value.value); break; case Types.TINYINT: node.put(value.column, (Byte) value.value); break; case Types.SMALLINT: node.put(value.column, (Short) value.value); break; case Types.INTEGER: node.put(value.column, (Integer) value.value); break; case Types.BIGINT: node.put(value.column, (Long) value.value); break; case Types.REAL: node.put(value.column, (Float) value.value); break; case Types.DOUBLE: node.put(value.column, (Double) value.value); break; case Types.VARBINARY: node.put(value.column, (byte[]) value.value); break; case Types.DATE: node.put(value.column, ((Date) value.value).getTime()); break; case Types.TIMESTAMP: node.put(value.column, ((Timestamp) value.value).getTime()); break; case Types.CLOB: case Types.BLOB: default: node.put(value.column, "Unsupported type=" + value.type); } } return node; }
From source file:com.streamsets.pipeline.lib.jdbc.JdbcUtil.java
public Field resultToField(ResultSetMetaData md, ResultSet rs, int columnIndex, int maxClobSize, int maxBlobSize, DataType userSpecifiedType, UnknownTypeAction unknownTypeAction, boolean timestampToString) throws SQLException, IOException, StageException { Field field;//w w w .j a v a 2s . c o m if (userSpecifiedType != DataType.USE_COLUMN_TYPE) { // If user specifies the data type, overwrite the column type returned by database. field = Field.create(Field.Type.valueOf(userSpecifiedType.getLabel()), rs.getObject(columnIndex)); } else { // All types as of JDBC 2.0 are here: // https://docs.oracle.com/javase/8/docs/api/constant-values.html#java.sql.Types.ARRAY // Good source of recommended mappings is here: // http://www.cs.mun.ca/java-api-1.5/guide/jdbc/getstart/mapping.html switch (md.getColumnType(columnIndex)) { case Types.BIGINT: field = Field.create(Field.Type.LONG, rs.getObject(columnIndex)); break; case Types.BINARY: case Types.LONGVARBINARY: case Types.VARBINARY: field = Field.create(Field.Type.BYTE_ARRAY, rs.getBytes(columnIndex)); break; case Types.BIT: case Types.BOOLEAN: field = Field.create(Field.Type.BOOLEAN, rs.getObject(columnIndex)); break; case Types.CHAR: case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.VARCHAR: field = Field.create(Field.Type.STRING, rs.getObject(columnIndex)); break; case Types.CLOB: case Types.NCLOB: field = Field.create(Field.Type.STRING, getClobString(rs.getClob(columnIndex), maxClobSize)); break; case Types.BLOB: field = Field.create(Field.Type.BYTE_ARRAY, getBlobBytes(rs.getBlob(columnIndex), maxBlobSize)); break; case Types.DATE: field = Field.create(Field.Type.DATE, rs.getDate(columnIndex)); break; case Types.DECIMAL: case Types.NUMERIC: field = Field.create(Field.Type.DECIMAL, rs.getBigDecimal(columnIndex)); field.setAttribute(HeaderAttributeConstants.ATTR_SCALE, String.valueOf(rs.getMetaData().getScale(columnIndex))); field.setAttribute(HeaderAttributeConstants.ATTR_PRECISION, String.valueOf(rs.getMetaData().getPrecision(columnIndex))); break; case Types.DOUBLE: field = Field.create(Field.Type.DOUBLE, rs.getObject(columnIndex)); break; case Types.FLOAT: case Types.REAL: field = Field.create(Field.Type.FLOAT, rs.getObject(columnIndex)); break; case Types.INTEGER: field = Field.create(Field.Type.INTEGER, rs.getObject(columnIndex)); break; case Types.ROWID: field = Field.create(Field.Type.STRING, rs.getRowId(columnIndex).toString()); break; case Types.SMALLINT: case Types.TINYINT: field = Field.create(Field.Type.SHORT, rs.getObject(columnIndex)); break; case Types.TIME: field = Field.create(Field.Type.TIME, rs.getObject(columnIndex)); break; case Types.TIMESTAMP: final Timestamp timestamp = rs.getTimestamp(columnIndex); if (timestampToString) { field = Field.create(Field.Type.STRING, timestamp == null ? null : timestamp.toString()); } else { field = Field.create(Field.Type.DATETIME, timestamp); if (timestamp != null) { final long actualNanos = timestamp.getNanos() % NANOS_TO_MILLIS_ADJUSTMENT; if (actualNanos > 0) { field.setAttribute(FIELD_ATTRIBUTE_NANOSECONDS, String.valueOf(actualNanos)); } } } break; // Ugly hack until we can support LocalTime, LocalDate, LocalDateTime, etc. case Types.TIME_WITH_TIMEZONE: OffsetTime offsetTime = rs.getObject(columnIndex, OffsetTime.class); field = Field.create(Field.Type.TIME, Date.from(offsetTime.atDate(LocalDate.MIN).toInstant())); break; case Types.TIMESTAMP_WITH_TIMEZONE: OffsetDateTime offsetDateTime = rs.getObject(columnIndex, OffsetDateTime.class); field = Field.create(Field.Type.ZONED_DATETIME, offsetDateTime.toZonedDateTime()); break; //case Types.REF_CURSOR: // JDK8 only case Types.SQLXML: case Types.STRUCT: case Types.ARRAY: case Types.DATALINK: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.NULL: case Types.OTHER: case Types.REF: default: if (unknownTypeAction == null) { return null; } switch (unknownTypeAction) { case STOP_PIPELINE: throw new StageException(JdbcErrors.JDBC_37, md.getColumnType(columnIndex), md.getColumnLabel(columnIndex)); case CONVERT_TO_STRING: Object value = rs.getObject(columnIndex); if (value != null) { field = Field.create(Field.Type.STRING, rs.getObject(columnIndex).toString()); } else { field = Field.create(Field.Type.STRING, null); } break; default: throw new IllegalStateException("Unknown action: " + unknownTypeAction); } } } return field; }
From source file:org.waarp.common.database.data.AbstractDbData.java
/** * Set the values from the Json node to the current object (no database access) * //from w ww. ja v a 2s. c om * @param node * @param ignorePrimaryKey * True will ignore primaryKey from Json * @throws WaarpDatabaseSqlException */ public void setFromJson(ObjectNode node, boolean ignorePrimaryKey) throws WaarpDatabaseSqlException { DbValue[] list = allFields; if (ignorePrimaryKey) { list = otherFields; } for (DbValue value : list) { if (value.column.equalsIgnoreCase("UPDATEDINFO")) { continue; } JsonNode item = node.get(value.column); if (item != null && !item.isMissingNode() && !item.isNull()) { isSaved = false; switch (value.type) { case Types.VARCHAR: case Types.LONGVARCHAR: value.setValue(item.asText()); break; case Types.BIT: value.setValue(item.asBoolean()); break; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: value.setValue(item.asInt()); break; case Types.BIGINT: value.setValue(item.asLong()); break; case Types.REAL: case Types.DOUBLE: value.setValue(item.asDouble()); break; case Types.VARBINARY: try { value.setValue(item.binaryValue()); } catch (IOException e) { throw new WaarpDatabaseSqlException("Issue while assigning array of bytes", e); } break; case Types.DATE: value.setValue(new Date(item.asLong())); break; case Types.TIMESTAMP: value.setValue(new Timestamp(item.asLong())); break; case Types.CLOB: case Types.BLOB: default: throw new WaarpDatabaseSqlException("Unsupported type: " + value.type); } } } setFromArray(); }
From source file:ca.sqlpower.architect.ddl.LiquibaseDDLGenerator.java
private boolean isNumericType(GenericTypeDescriptor td) { int type = td.getDataType(); return (type == Types.BIGINT || type == Types.INTEGER || type == Types.DECIMAL || type == Types.DOUBLE || type == Types.FLOAT || type == Types.NUMERIC || type == Types.REAL || type == Types.SMALLINT || type == Types.TINYINT); }