List of usage examples for java.sql Types VARCHAR
int VARCHAR
To view the source code for java.sql Types VARCHAR.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR
.
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswPgSql.CFFswPgSqlSecDeviceTable.java
public void createSecDevice(CFFswAuthorization Authorization, CFFswSecDeviceBuff Buff) { final String S_ProcName = "createSecDevice"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }// w w w . j a v a 2 s . c o m ResultSet resultSet = null; try { UUID SecUserId = Buff.getRequiredSecUserId(); String DevName = Buff.getRequiredDevName(); String PubKey = Buff.getOptionalPubKey(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerDbSchemaName() + ".sp_create_secdev( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "SDEV"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, DevName); if (PubKey != null) { stmtCreateByPKey.setString(argIdx++, PubKey); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFFswSecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredDevName(createdBuff.getRequiredDevName()); Buff.setOptionalPubKey(createdBuff.getOptionalPubKey()); 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:org.apache.camel.processor.aggregate.jdbc.OptimisticLockingJdbcAggregationRepository.java
@Override public Exchange add(CamelContext camelContext, String key, Exchange exchange) { return getTransactionTemplate().execute(new TransactionCallback<Exchange>() { @Override//from w w w. j a v a 2 s . c o m public Exchange doInTransaction(TransactionStatus status) { Exchange result = get(camelContext, key); try { log.debug(String.format("Adding exchange with key: [%s]", key)); byte[] marshalledExchange = getCodec().marshallExchange(camelContext, exchange, true); boolean present = getJdbcTemplate().queryForObject( String.format("SELECT COUNT(*) FROM %1$s WHERE %2$s=?", getRepositoryName(), ID_KEY), new Object[] { key }, new int[] { Types.VARCHAR }, Integer.class) != 0; if (present) { long version = exchange.getProperty(VERSION_EXCHANGE_PROPERTY, Long.class); log.debug(String.format("Updating record with key: [%s] and version: [%s].", key, version)); int affectedRows = getJdbcTemplate().update( String.format("UPDATE %1$s SET %2$s=?, %3$s=? WHERE %4$s=? AND %3$s=?", getRepositoryName(), EXCHANGE_KEY, VERSION_KEY, ID_KEY), new Object[] { new SqlLobValue(marshalledExchange, getLobHandler()), version + 1, key, version }, new int[] { Types.BLOB, Types.BIGINT, Types.VARCHAR, Types.BIGINT }); if (affectedRows < 1) { throw new RuntimeException(String.format( "Error updating record with key: [%s] and version: [%s]. Stale version...", key, version)); } } else { log.debug(String.format("Inserting record with key: [%s].", key)); getJdbcTemplate().update( String.format("INSERT INTO %1$s (%2$s, %3$s, %4$s) VALUES (?, ?, ?)", getRepositoryName(), ID_KEY, EXCHANGE_KEY, VERSION_KEY), new Object[] { key, new SqlLobValue(marshalledExchange, getLobHandler()), 1L }, new int[] { Types.VARCHAR, Types.BLOB, Types.BIGINT }); } } catch (Exception e) { throw new RuntimeException(String.format("Error adding to repository [%s] with key [%s].", getRepositoryName(), key), e); } return result; } }); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlSecDeviceTable.java
public void createSecDevice(CFAstAuthorization Authorization, CFAstSecDeviceBuff Buff) { final String S_ProcName = "createSecDevice"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w w w.j ava2 s . c om*/ ResultSet resultSet = null; try { UUID SecUserId = Buff.getRequiredSecUserId(); String DevName = Buff.getRequiredDevName(); String PubKey = Buff.getOptionalPubKey(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerDbSchemaName() + ".sp_create_secdev( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "SDEV"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, DevName); if (PubKey != null) { stmtCreateByPKey.setString(argIdx++, PubKey); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFAstSecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredDevName(createdBuff.getRequiredDevName()); Buff.setOptionalPubKey(createdBuff.getOptionalPubKey()); 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:com.sr.model.dao.IMahasiswaDAOImpl.java
@Override public boolean insertBiodata(Mahasiswa mhs, AkademikSR aka, FileItem foto, List<Prestasi> prestasi) { try {//from ww w .ja v a2 s . com LobHandler lobHandler = new DefaultLobHandler(); getJdbcTemplate().update(INSERT_BIODATA, new Object[] { mhs.getNamaMhs(), mhs.getTempat_lahir(), mhs.getTanggal_lahir(), mhs.getAgama(), mhs.getKelamin(), mhs.getAlamat_asal(), mhs.getKab_kota_asal(), mhs.getProv_asal(), mhs.getNo_hp_mhs(), mhs.getNama_ayah(), mhs.getNama_ibu(), mhs.getPendidikan_ayah(), mhs.getPendidikan_ibu(), mhs.getPekerjaan_ayah(), mhs.getPekerjaan_ibu(), mhs.getPendapatan_ortu(), mhs.getNo_tel_ortu(), mhs.getNo_hp_ortu(), mhs.getAlamat_keluarga(), mhs.getNo_tel_keluarga(), mhs.getNo_hp_keluarga(), new SqlLobValue(foto.getInputStream(), (int) foto.getSize(), lobHandler), mhs.getNim() }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.NUMERIC, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.VARCHAR }); getJdbcTemplate().update(INSERT_AKADEMIK, new Object[] { aka.getProdi(), aka.getIpk_masuk(), aka.getSemester(), aka.getRapor_smu(), aka.getJurusan(), aka.getFakultas(), aka.getNim() }, new int[] { Types.VARCHAR, Types.DECIMAL, Types.NUMERIC, Types.DECIMAL, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }); for (Prestasi pres : prestasi) { getJdbcTemplate().update(INSERT_PRESTASI, new Object[] { pres.getNo_sertifikat(), pres.getNim(), pres.getNama_prestasi(), pres.getJenis_prestasi() }); } return true; } catch (DataAccessException da) { System.out.println("DataAccessException" + da.getMessage()); } catch (FileNotFoundException ex) { System.out.println("FileNotFoundException " + ex.getMessage()); } catch (IOException ex) { System.out.println(ex.getMessage()); } return false; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleISOCurrencyTable.java
public void createISOCurrency(CFSecurityAuthorization Authorization, CFSecurityISOCurrencyBuff Buff) { final String S_ProcName = "createISOCurrency"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w w w .jav a2 s. c o m*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { short Id = Buff.getRequiredId(); String ISOCode = Buff.getRequiredISOCode(); String Name = Buff.getRequiredName(); String UnitSymbol = Buff.getOptionalUnitSymbol(); String FracSymbol = Buff.getOptionalFracSymbol(); short Precis = Buff.getRequiredPrecis(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall( "begin " + schema.getLowerDbSchemaName() + ".crt_iso_ccy( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); 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++, "ISCY"); stmtCreateByPKey.setShort(argIdx++, Id); stmtCreateByPKey.setString(argIdx++, ISOCode); stmtCreateByPKey.setString(argIdx++, Name); if (UnitSymbol != null) { stmtCreateByPKey.setString(argIdx++, UnitSymbol); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FracSymbol != null) { stmtCreateByPKey.setString(argIdx++, FracSymbol); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.setShort(argIdx++, Precis); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_iso_ccy() did not return a result set"); } try { if (resultSet.next()) { CFSecurityISOCurrencyBuff createdBuff = unpackISOCurrencyResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setRequiredISOCode(createdBuff.getRequiredISOCode()); Buff.setRequiredName(createdBuff.getRequiredName()); Buff.setOptionalUnitSymbol(createdBuff.getOptionalUnitSymbol()); Buff.setOptionalFracSymbol(createdBuff.getOptionalFracSymbol()); Buff.setRequiredPrecis(createdBuff.getRequiredPrecis()); 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().newRuntimeException(getClass(), S_ProcName, "crt_iso_ccy() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlDomainBaseTable.java
public void createDomainBase(CFSecurityAuthorization Authorization, CFInternetDomainBaseBuff Buff) { final String S_ProcName = "createDomainBase"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*w w w. j a va2 s. c o m*/ ResultSet resultSet = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getOptionalDescription(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerDbSchemaName() + ".sp_create_bdomdef( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; 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++, ClassCode); stmtCreateByPKey.setLong(argIdx++, TenantId); if (Description != null) { stmtCreateByPKey.setString(argIdx++, Description); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFInternetDomainBaseBuff createdBuff = unpackDomainBaseResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalDescription(createdBuff.getOptionalDescription()); 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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWTagTable.java
public void createTag(CFAccAuthorization Authorization, CFAccTagBuff Buff) { final String S_ProcName = "createTag"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }// w ww . j av a 2s. com ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); String Descr = Buff.getOptionalDescr(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_create_tag( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "CTAG"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); if (Descr != null) { stmtCreateByPKey.setString(argIdx++, Descr); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFAccTagBuff createdBuff = unpackTagResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setRequiredName(createdBuff.getRequiredName()); Buff.setOptionalDescr(createdBuff.getOptionalDescr()); 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.cfacc.v2_0.CFAccMySql.CFAccMySqlTagTable.java
public void createTag(CFAccAuthorization Authorization, CFAccTagBuff Buff) { final String S_ProcName = "createTag"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w w w .java 2s. c om*/ ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); String Descr = Buff.getOptionalDescr(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_tag( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "CTAG"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); if (Descr != null) { stmtCreateByPKey.setString(argIdx++, Descr); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } try { resultSet = stmtCreateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFAccTagBuff createdBuff = unpackTagResultSetToBuff(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.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setRequiredName(createdBuff.getRequiredName()); Buff.setOptionalDescr(createdBuff.getOptionalDescr()); 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.cfacc.v2_0.CFAccMSSql.CFAccMSSqlTagTable.java
public void createTag(CFAccAuthorization Authorization, CFAccTagBuff Buff) { final String S_ProcName = "createTag"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w w w . j a v a2 s. c o m ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); String Name = Buff.getRequiredName(); String Descr = Buff.getOptionalDescr(); Connection cnx = schema.getCnx(); String sql = "exec sp_create_tag ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"; 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++, "CTAG"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setString(argIdx++, Name); if (Descr != null) { stmtCreateByPKey.setString(argIdx++, Descr); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } 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()) { CFAccTagBuff createdBuff = unpackTagResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setRequiredName(createdBuff.getRequiredName()); Buff.setOptionalDescr(createdBuff.getOptionalDescr()); 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.cffreeswitch.v2_1.CFFswOracle.CFFswOracleSecDeviceTable.java
public void createSecDevice(CFFswAuthorization Authorization, CFFswSecDeviceBuff Buff) { final String S_ProcName = "createSecDevice"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from www . j ava 2 s . c om ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { UUID SecUserId = Buff.getRequiredSecUserId(); String DevName = Buff.getRequiredDevName(); String PubKey = Buff.getOptionalPubKey(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_secdev( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); 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++, "SDEV"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, DevName); if (PubKey != null) { stmtCreateByPKey.setString(argIdx++, PubKey); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_secdev() did not return a result set"); } try { if (resultSet.next()) { CFFswSecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredDevName(createdBuff.getRequiredDevName()); Buff.setOptionalPubKey(createdBuff.getOptionalPubKey()); 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().newRuntimeException(getClass(), S_ProcName, "crt_secdev() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }