List of usage examples for java.sql Types INTEGER
int INTEGER
To view the source code for java.sql Types INTEGER.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER
.
From source file:helma.objectmodel.db.NodeManager.java
private void setStatementValue(PreparedStatement stmt, int stmtNumber, Property p, int columnType) throws SQLException { if (p.getValue() == null) { stmt.setNull(stmtNumber, columnType); } else {/*from w w w . ja v a 2s .com*/ switch (columnType) { case Types.BIT: case Types.BOOLEAN: stmt.setBoolean(stmtNumber, p.getBooleanValue()); break; case Types.TINYINT: case Types.BIGINT: case Types.SMALLINT: case Types.INTEGER: stmt.setLong(stmtNumber, p.getIntegerValue()); break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: case Types.NUMERIC: case Types.DECIMAL: stmt.setDouble(stmtNumber, p.getFloatValue()); break; case Types.LONGVARBINARY: case Types.VARBINARY: case Types.BINARY: case Types.BLOB: Object b = p.getJavaObjectValue(); if (b instanceof byte[]) { byte[] buf = (byte[]) b; try { stmt.setBytes(stmtNumber, buf); } catch (SQLException x) { ByteArrayInputStream bout = new ByteArrayInputStream(buf); stmt.setBinaryStream(stmtNumber, bout, buf.length); } } else { throw new SQLException( "expected byte[] for binary column '" + p.getName() + "', found " + b.getClass()); } break; case Types.LONGVARCHAR: try { stmt.setString(stmtNumber, p.getStringValue()); } catch (SQLException x) { String str = p.getStringValue(); Reader r = new StringReader(str); stmt.setCharacterStream(stmtNumber, r, str.length()); } break; case Types.CLOB: String val = p.getStringValue(); Reader isr = new StringReader(val); stmt.setCharacterStream(stmtNumber, isr, val.length()); break; case Types.CHAR: case Types.VARCHAR: case Types.OTHER: stmt.setString(stmtNumber, p.getStringValue()); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: stmt.setTimestamp(stmtNumber, p.getTimestampValue()); break; case Types.NULL: stmt.setNull(stmtNumber, 0); break; default: stmt.setString(stmtNumber, p.getStringValue()); break; } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPopTable.java
public void deleteGelPopByPrevIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argPrevId) {//from ww w . ja v a 2 s . c o m final String S_ProcName = "deleteGelPopByPrevIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelpop_by_previdx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByPrevIdx == null) { stmtDeleteByPrevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPrevIdx.setLong(argIdx++, argTenantId); stmtDeleteByPrevIdx.setLong(argIdx++, argCartridgeId); if (argPrevId != null) { stmtDeleteByPrevIdx.setInt(argIdx++, argPrevId.intValue()); } else { stmtDeleteByPrevIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByPrevIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelReferenceTable.java
public void deleteGelReferenceByPrevIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argPrevId) { final String S_ProcName = "deleteGelReferenceByPrevIdx"; ResultSet resultSet = null;//from w w w. j av a2 s . com try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelrefer_by_previdx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByPrevIdx == null) { stmtDeleteByPrevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPrevIdx.setLong(argIdx++, argTenantId); stmtDeleteByPrevIdx.setLong(argIdx++, argCartridgeId); if (argPrevId != null) { stmtDeleteByPrevIdx.setInt(argIdx++, argPrevId.intValue()); } else { stmtDeleteByPrevIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByPrevIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPrefixLineTable.java
public void deleteGelPrefixLineByPrevIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argPrevId) { final String S_ProcName = "deleteGelPrefixLineByPrevIdx"; ResultSet resultSet = null;/* w w w . ja v a2 s . co m*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelprefix_by_previdx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByPrevIdx == null) { stmtDeleteByPrevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPrevIdx.setLong(argIdx++, argTenantId); stmtDeleteByPrevIdx.setLong(argIdx++, argCartridgeId); if (argPrevId != null) { stmtDeleteByPrevIdx.setInt(argIdx++, argPrevId.intValue()); } else { stmtDeleteByPrevIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByPrevIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbOracle.CFGenKbOracleGelExpansionTable.java
public void deleteGelExpansionByPrevIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argPrevId) { final String S_ProcName = "deleteGelExpansionByPrevIdx"; ResultSet resultSet = null;/*w w w . ja va 2 s . c o m*/ try { Connection cnx = schema.getCnx(); String sql = "begin call " + schema.getLowerSchemaDbName() + ".dl_gelexpansionbyprevidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end"; if (stmtDeleteByPrevIdx == null) { stmtDeleteByPrevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPrevIdx.setLong(argIdx++, argTenantId); stmtDeleteByPrevIdx.setLong(argIdx++, argCartridgeId); if (argPrevId != null) { stmtDeleteByPrevIdx.setInt(argIdx++, argPrevId.intValue()); } else { stmtDeleteByPrevIdx.setNull(argIdx++, java.sql.Types.INTEGER); } int rowsUpdated = stmtDeleteByPrevIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPopTable.java
public void deleteGelPopByNextIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argNextId) {/* w ww.j a v a 2s. c o m*/ final String S_ProcName = "deleteGelPopByNextIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelpop_by_nextidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByNextIdx == null) { stmtDeleteByNextIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByNextIdx.setLong(argIdx++, argTenantId); stmtDeleteByNextIdx.setLong(argIdx++, argCartridgeId); if (argNextId != null) { stmtDeleteByNextIdx.setInt(argIdx++, argNextId.intValue()); } else { stmtDeleteByNextIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByNextIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:edu.pitt.apollo.db.ApolloDbUtils.java
public BigInteger[] addSimulationRun(RunMessage runMessage, int md5CollisionId, SoftwareIdentification identificationOfSoftwareToRun, int sourceSoftwareIdKey, SoftwareIdentification destinationSoftwareForRunSimulationMessage, Authentication authentication) throws ApolloDatabaseException, Md5UtilsException { String userName = authentication.getRequesterId(); String password = authentication.getRequesterPassword(); runMessage.setAuthentication(new Authentication()); String[] userIdTokens = parseUserId(userName); userName = userIdTokens[0];//from w w w. j a v a 2 s.com Integer softwareKey = null; if (identificationOfSoftwareToRun != null) { softwareKey = getSoftwareIdentificationKey(identificationOfSoftwareToRun); } int userKey = getUserKey(userName, password); BigInteger simulationGroupId = null; String additionalInsertField = ""; String additionalParamHolder = ""; BigInteger[] runIdSimulationGroupId = new BigInteger[2]; String md5 = md5Utils.getMd5(runMessage); try (Connection conn = datasource.getConnection()) { simulationGroupId = getNewSimulationGroupId(); runIdSimulationGroupId[1] = simulationGroupId; additionalInsertField = ", simulation_group_id"; additionalParamHolder = ",?"; String query = "INSERT IGNORE INTO run (md5_hash_of_run_message, software_id, requester_id, last_service_to_be_called, md5_collision_id " + additionalInsertField + ") VALUES (?, ?, ?, ?, ? " + additionalParamHolder + ")"; PreparedStatement pstmt = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); pstmt.setString(1, md5); if (softwareKey != null) { pstmt.setInt(2, softwareKey); } else { pstmt.setNull(2, Types.INTEGER); } pstmt.setInt(3, userKey); pstmt.setInt(4, 1); pstmt.setInt(5, md5CollisionId); pstmt.setLong(6, simulationGroupId.longValue()); ResultSet rs; int rowsAffected = pstmt.executeUpdate(); if (rowsAffected > 0) { rs = pstmt.getGeneratedKeys(); } else { query = "SELECT id FROM run WHERE md5_hash_of_run_message = ? and md5_collision_id = ?"; pstmt = conn.prepareStatement(query); pstmt.setString(1, md5); pstmt.setInt(2, md5CollisionId); rs = pstmt.executeQuery(); } BigInteger runId; if (rs.next()) { runId = new BigInteger(rs.getString(1)); } else { throw new ApolloDatabaseRecordNotInsertedException("Record not inserted!"); } List<BigInteger> runIds = new ArrayList<>(); runIds.add(runId); if (!(runMessage instanceof RunSimulationsMessage)) { addRunIdsToSimulationGroup(simulationGroupId, runIds); } // ALSO NEED TO ADD serialized runSimulationMessage(JSON) to // run_data_content table... // use insertDataContentForRun for this int dataContentKey = addTextDataContent(jsonUtils.getJSONString(runMessage)); int runDataDescriptionId = getRunDataDescriptionId(ContentDataFormatEnum.TEXT, "run_message.json", ContentDataTypeEnum.RUN_MESSAGE, sourceSoftwareIdKey, getSoftwareIdentificationKey(destinationSoftwareForRunSimulationMessage)); // int runDataId = the following line returns the runDataId, but // it's not used at this point. associateContentWithRunId(new BigInteger(String.valueOf(runId)), dataContentKey, runDataDescriptionId); runIdSimulationGroupId[0] = runId; if (runIdSimulationGroupId.length == 2) { runIdSimulationGroupId[1] = simulationGroupId; } updateStatusOfRun(runId, MethodCallStatusEnum.LOADED_RUN_CONFIG_INTO_DATABASE, "Adding config information to the database for runId: " + runId.toString()); return runIdSimulationGroupId; // } catch (ClassNotFoundException ex) { // throw new ApolloDatabaseException( // "ClassNotFoundException attempting to add simulation run: " // + ex.getMessage()); } catch (SQLException ex) { throw new ApolloDatabaseException("SQLException attempting to add simulation run: " + ex.getMessage()); } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelReferenceTable.java
public void deleteGelReferenceByNextIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argNextId) { final String S_ProcName = "deleteGelReferenceByNextIdx"; ResultSet resultSet = null;//from w ww. ja v a2s . c o m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelrefer_by_nextidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByNextIdx == null) { stmtDeleteByNextIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByNextIdx.setLong(argIdx++, argTenantId); stmtDeleteByNextIdx.setLong(argIdx++, argCartridgeId); if (argNextId != null) { stmtDeleteByNextIdx.setInt(argIdx++, argNextId.intValue()); } else { stmtDeleteByNextIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByNextIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPrefixLineTable.java
public void deleteGelPrefixLineByNextIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argNextId) { final String S_ProcName = "deleteGelPrefixLineByNextIdx"; ResultSet resultSet = null;/* w w w. j ava 2 s. com*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelprefix_by_nextidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByNextIdx == null) { stmtDeleteByNextIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByNextIdx.setLong(argIdx++, argTenantId); stmtDeleteByNextIdx.setLong(argIdx++, argCartridgeId); if (argNextId != null) { stmtDeleteByNextIdx.setInt(argIdx++, argNextId.intValue()); } else { stmtDeleteByNextIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByNextIdx.executeUpdate(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }