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:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWContactListTable.java
public void createContactList(CFCrmAuthorization Authorization, CFCrmContactListBuff Buff) { final String S_ProcName = "createContactList"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w ww . j a v a2 s .co m*/ ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getRequiredDescription(); Integer StripDigits = Buff.getOptionalStripDigits(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_create_ctclst( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "CTL"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Description); if (StripDigits != null) { stmtCreateByPKey.setInt(argIdx++, StripDigits.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFCrmContactListBuff createdBuff = unpackContactListResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactListId(createdBuff.getRequiredContactListId()); Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setOptionalStripDigits(createdBuff.getOptionalStripDigits()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } 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.cfcrm.v2_1.CFCrmSybase.CFCrmSybaseContactListTable.java
public void createContactList(CFCrmAuthorization Authorization, CFCrmContactListBuff Buff) { final String S_ProcName = "createContactList"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w ww.ja v a2 s. c o m ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getRequiredDescription(); Integer StripDigits = Buff.getOptionalStripDigits(); Connection cnx = schema.getCnx(); String sql = "exec sp_create_ctclst ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "CTL"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Description); if (StripDigits != null) { stmtCreateByPKey.setInt(argIdx++, StripDigits.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFCrmContactListBuff createdBuff = unpackContactListResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactListId(createdBuff.getRequiredContactListId()); Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setOptionalStripDigits(createdBuff.getOptionalStripDigits()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } 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:de.whs.poodle.repositories.McQuestionRepository.java
public int save(McQuestion question) { if (question.getText().trim().isEmpty()) throw new BadRequestException("noExerciseTextSpecified"); for (Answer a : question.getAnswers()) { if (a.getText().trim().isEmpty()) throw new BadRequestException("emptyAnswer"); }// w ww.j a v a2s . c o m return jdbc.execute(new ConnectionCallback<Integer>() { @Override public Integer doInConnection(Connection con) throws SQLException, DataAccessException { try (PreparedStatement questionPs = con.prepareStatement( "INSERT INTO mc_question(course_id,text,has_multiple_correct_answers,changed_by_id,root_id,visibility,comment) VALUES(?,?,?,?,?,?::exercise_visibility,?)", PreparedStatement.RETURN_GENERATED_KEYS); PreparedStatement answersPs = con.prepareStatement( "INSERT INTO mc_question_to_answer(mc_question_id,correct,text) VALUES(?,?,?)"); PreparedStatement tagsPs = con.prepareStatement( "INSERT INTO mc_question_to_tag(mc_question_id,tag_id) VALUES(?,?)"); /* If this is a new revision, this updates the revision in existing worksheets. * Note that we only do this if no statistics exist yet, because we would screw * those up otherwise (the answer IDs in mc_chosen_answer wouldn't match the * question revision anymore). */ PreparedStatement updateWorksheetsPs = con .prepareStatement("UPDATE mc_worksheet_to_question wtq SET mc_question_id = ? " + "WHERE mc_question_id IN (SELECT id FROM mc_question WHERE root_id = ?) " + "AND NOT EXISTS (SELECT 1 FROM mc_statistic WHERE mc_worksheet_to_question_id = wtq.id)");) { con.setAutoCommit(false); // inner try for rollback try { // exercise questionPs.setInt(1, question.getCourseId()); questionPs.setString(2, question.getText()); questionPs.setBoolean(3, question.isMultipleCorrectAnswers()); questionPs.setInt(4, question.getChangedBy().getId()); /* * The root id is always the ID of the first revision. If this * is a new exercise, this ID obviously doesn't exist yet. We set * NULL in this case, but a trigger in the DB will automatically * set the root_id to the generated id. */ if (question.getRootId() == 0) questionPs.setNull(5, Types.INTEGER); else questionPs.setInt(5, question.getRootId()); questionPs.setString(6, question.getVisibility().toString()); questionPs.setString(7, question.getComment()); questionPs.executeUpdate(); ResultSet genRs = questionPs.getGeneratedKeys(); genRs.next(); int questionId = genRs.getInt(1); // answers answersPs.setInt(1, questionId); for (Answer a : question.getAnswers()) { answersPs.setBoolean(2, a.isCorrect()); answersPs.setString(3, a.getText()); answersPs.addBatch(); } answersPs.executeBatch(); // tag relations tagsPs.setInt(1, questionId); for (Tag t : question.getTags()) { tagsPs.setInt(2, t.getId()); tagsPs.addBatch(); } tagsPs.executeBatch(); // if this is new revision, update it in the worksheets if (question.getRootId() != 0) { updateWorksheetsPs.setInt(1, questionId); updateWorksheetsPs.setInt(2, question.getRootId()); updateWorksheetsPs.executeUpdate(); } con.commit(); return questionId; } catch (SQLException e) { con.rollback(); throw e; } finally { con.setAutoCommit(true); } } } }); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlContactListTable.java
public void createContactList(CFCrmAuthorization Authorization, CFCrmContactListBuff Buff) { final String S_ProcName = "createContactList"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w w w . ja va 2s . c om*/ ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getRequiredDescription(); Integer StripDigits = Buff.getOptionalStripDigits(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_ctclst( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "CTL"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Description); if (StripDigits != null) { stmtCreateByPKey.setInt(argIdx++, StripDigits.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } try { resultSet = stmtCreateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFCrmContactListBuff createdBuff = unpackContactListResultSetToBuff(resultSet); if ((resultSet != null) && resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactListId(createdBuff.getRequiredContactListId()); Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setOptionalStripDigits(createdBuff.getOptionalStripDigits()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } 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.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlContactListTable.java
public void createContactList(CFCrmAuthorization Authorization, CFCrmContactListBuff Buff) { final String S_ProcName = "createContactList"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w ww . j a va2 s .c om*/ ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getRequiredDescription(); Integer StripDigits = Buff.getOptionalStripDigits(); Connection cnx = schema.getCnx(); String sql = "exec sp_create_ctclst ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "CTL"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Description); if (StripDigits != null) { stmtCreateByPKey.setInt(argIdx++, StripDigits.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } stmtCreateByPKey.execute(); boolean moreResults = true; resultSet = null; while (resultSet == null) { try { moreResults = stmtCreateByPKey.getMoreResults(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (moreResults) { try { resultSet = stmtCreateByPKey.getResultSet(); } catch (SQLException e) { } } else if (-1 == stmtCreateByPKey.getUpdateCount()) { break; } } if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "resultSet"); } if (resultSet.next()) { CFCrmContactListBuff createdBuff = unpackContactListResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactListId(createdBuff.getRequiredContactListId()); Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setOptionalStripDigits(createdBuff.getOptionalStripDigits()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } 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.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java
public int nextSecAppIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) { final String S_ProcName = "nextSecAppIdGen"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Not in a transaction"); }// www. j a v a2 s . co m Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); CallableStatement stmtSelectNextSecAppIdGen = null; try { String sql = "{ call sp_next_secappidgen( ?" + ", " + "?" + " ) }"; stmtSelectNextSecAppIdGen = cnx.prepareCall(sql); int argIdx = 1; stmtSelectNextSecAppIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER); stmtSelectNextSecAppIdGen.setLong(argIdx++, Id); stmtSelectNextSecAppIdGen.execute(); int nextId = stmtSelectNextSecAppIdGen.getInt(1); return (nextId); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (stmtSelectNextSecAppIdGen != null) { try { stmtSelectNextSecAppIdGen.close(); } catch (SQLException e) { } stmtSelectNextSecAppIdGen = null; } } }
From source file:architecture.ee.web.logo.dao.jdbc.JdbcLogoImageDao.java
public void updateLogoImage(LogoImage logoImage, InputStream is) { if (logoImage.isPrimary()) { getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_WEB.RESET_LOGO_IMAGE_BY_OBJECT_TYPE_AND_OBJECT_ID").getSql(), new SqlParameterValue(Types.INTEGER, logoImage.getObjectType()), new SqlParameterValue(Types.NUMERIC, logoImage.getObjectId())); }//from w ww.j a v a 2s.com getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_WEB.UPDATE_LOGO_IMAGE").getSql(), new SqlParameterValue(Types.NUMERIC, logoImage.getObjectType()), new SqlParameterValue(Types.NUMERIC, logoImage.getObjectId()), new SqlParameterValue(Types.NUMERIC, logoImage.isPrimary() ? 1 : 0), new SqlParameterValue(Types.VARCHAR, logoImage.getFilename()), new SqlParameterValue(Types.NUMERIC, logoImage.getImageSize()), new SqlParameterValue(Types.VARCHAR, logoImage.getImageContentType()), new SqlParameterValue(Types.DATE, logoImage.getModifiedDate()), new SqlParameterValue(Types.NUMERIC, logoImage.getLogoId())); if (is != null) updateImageImputStream(logoImage, is); }
From source file:edu.harvard.i2b2.crc.dao.setfinder.QueryResultInstanceSpringDao.java
/** * Function used to update result instance Particularly its status and size * //w w w .j a va2s .c o m * @param resultInstanceId * @param statusTypeId * @param setSize */ public void updatePatientSet(String resultInstanceId, int statusTypeId, String message, int setSize, int realSetSize, String obsMethod) { Date endDate = new Date(System.currentTimeMillis()); String sql = "update " + getDbSchemaName() + "qt_query_result_instance set set_size = ?, real_set_size = ? , obfusc_method = ?, status_type_id =?, end_date = ?, message = ? where result_instance_id = ?"; jdbcTemplate.update(sql, new Object[] { setSize, realSetSize, obsMethod, statusTypeId, endDate, message, resultInstanceId }, new int[] { Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER }); }
From source file:com.xpfriend.fixture.cast.temp.TypeConverter.java
private static Class<?> getJavaType(int sqltype, int precision, int scale) { switch (sqltype) { case Types.BIGINT: return Long.class; case Types.BIT: return Boolean.class; case Types.BOOLEAN: return Boolean.class; case Types.CHAR: return String.class; case Types.DECIMAL: return getNumericType(precision, scale); case Types.DOUBLE: return Double.class; case Types.FLOAT: return Double.class; case Types.INTEGER: return Integer.class; case Types.LONGVARCHAR: return String.class; case Types.NUMERIC: return getNumericType(precision, scale); case Types.REAL: return Float.class; case Types.SMALLINT: return Short.class; case Types.DATE: return java.sql.Timestamp.class; case Types.TIME: return java.sql.Time.class; case Types.TIMESTAMP: return java.sql.Timestamp.class; case Types.TINYINT: return Byte.class; case Types.VARCHAR: return String.class; case Types.BLOB: return byte[].class; case Types.LONGVARBINARY: return byte[].class; case Types.CLOB: return String.class; case Types.BINARY: return byte[].class; case Types.VARBINARY: return byte[].class; case Types.NVARCHAR: return String.class; case Types.NCHAR: return String.class; case Types.LONGNVARCHAR: return String.class; case -155:// www .j av a 2 s . c o m return java.sql.Timestamp.class; default: return Object.class; } }