List of usage examples for java.lang Short shortValue
@HotSpotIntrinsicCandidate public short shortValue()
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlContactTable.java
public void updateContact(CFCrmAuthorization Authorization, CFCrmContactBuff Buff) { final String S_ProcName = "updateContact"; ResultSet resultSet = null;/* w ww . j a va2 s. c o m*/ try { long TenantId = Buff.getRequiredTenantId(); long ContactId = Buff.getRequiredContactId(); long ContactListId = Buff.getRequiredContactListId(); Short ISOTimezoneId = Buff.getOptionalISOTimezoneId(); String FullName = Buff.getRequiredFullName(); String LastName = Buff.getOptionalLastName(); String FirstName = Buff.getOptionalFirstName(); String Custom = Buff.getOptionalCustom(); String Custom2 = Buff.getOptionalCustom2(); String Custom3 = Buff.getOptionalCustom3(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "exec sp_update_contact ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CTC"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setLong(argIdx++, ContactListId); if (ISOTimezoneId != null) { stmtUpdateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, FullName); if (LastName != null) { stmtUpdateByPKey.setString(argIdx++, LastName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FirstName != null) { stmtUpdateByPKey.setString(argIdx++, FirstName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom != null) { stmtUpdateByPKey.setString(argIdx++, Custom); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom2 != null) { stmtUpdateByPKey.setString(argIdx++, Custom2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom3 != null) { stmtUpdateByPKey.setString(argIdx++, Custom3); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); stmtUpdateByPKey.execute(); boolean moreResults = true; resultSet = null; while (resultSet == null) { try { moreResults = stmtUpdateByPKey.getMoreResults(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (moreResults) { try { resultSet = stmtUpdateByPKey.getResultSet(); } catch (SQLException e) { } } else if (-1 == stmtUpdateByPKey.getUpdateCount()) { break; } } if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "resultSet"); } if (resultSet.next()) { CFCrmContactBuff updatedBuff = unpackContactResultSetToBuff(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(updatedBuff.getRequiredContactListId()); Buff.setOptionalISOTimezoneId(updatedBuff.getOptionalISOTimezoneId()); Buff.setRequiredFullName(updatedBuff.getRequiredFullName()); Buff.setOptionalLastName(updatedBuff.getOptionalLastName()); Buff.setOptionalFirstName(updatedBuff.getOptionalFirstName()); Buff.setOptionalCustom(updatedBuff.getOptionalCustom()); Buff.setOptionalCustom2(updatedBuff.getOptionalCustom2()); Buff.setOptionalCustom3(updatedBuff.getOptionalCustom3()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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.CFAccMySqlContactTable.java
public void updateContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) { final String S_ProcName = "updateContact"; ResultSet resultSet = null;/*from w w w . ja v a 2 s .c o m*/ try { long TenantId = Buff.getRequiredTenantId(); long ContactId = Buff.getRequiredContactId(); long ContactListId = Buff.getRequiredContactListId(); Short ISOTimezoneId = Buff.getOptionalISOTimezoneId(); String FullName = Buff.getRequiredFullName(); String LastName = Buff.getOptionalLastName(); String FirstName = Buff.getOptionalFirstName(); String Custom = Buff.getOptionalCustom(); String Custom2 = Buff.getOptionalCustom2(); String Custom3 = Buff.getOptionalCustom3(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_update_contact( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CTC"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setLong(argIdx++, ContactListId); if (ISOTimezoneId != null) { stmtUpdateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, FullName); if (LastName != null) { stmtUpdateByPKey.setString(argIdx++, LastName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FirstName != null) { stmtUpdateByPKey.setString(argIdx++, FirstName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom != null) { stmtUpdateByPKey.setString(argIdx++, Custom); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom2 != null) { stmtUpdateByPKey.setString(argIdx++, Custom2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom3 != null) { stmtUpdateByPKey.setString(argIdx++, Custom3); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); try { resultSet = stmtUpdateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFAccContactBuff updatedBuff = unpackContactResultSetToBuff(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(updatedBuff.getRequiredContactListId()); Buff.setOptionalISOTimezoneId(updatedBuff.getOptionalISOTimezoneId()); Buff.setRequiredFullName(updatedBuff.getRequiredFullName()); Buff.setOptionalLastName(updatedBuff.getOptionalLastName()); Buff.setOptionalFirstName(updatedBuff.getOptionalFirstName()); Buff.setOptionalCustom(updatedBuff.getOptionalCustom()); Buff.setOptionalCustom2(updatedBuff.getOptionalCustom2()); Buff.setOptionalCustom3(updatedBuff.getOptionalCustom3()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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.CFAccPgSql.CFAccPgSqlContactTable.java
public void updateContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) { final String S_ProcName = "updateContact"; ResultSet resultSet = null;//from w w w . j ava2s .c o m try { long TenantId = Buff.getRequiredTenantId(); long ContactId = Buff.getRequiredContactId(); long ContactListId = Buff.getRequiredContactListId(); Short ISOTimezoneId = Buff.getOptionalISOTimezoneId(); String FullName = Buff.getRequiredFullName(); String LastName = Buff.getOptionalLastName(); String FirstName = Buff.getOptionalFirstName(); String Custom = Buff.getOptionalCustom(); String Custom2 = Buff.getOptionalCustom2(); String Custom3 = Buff.getOptionalCustom3(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_update_contact( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CTC"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setLong(argIdx++, ContactListId); if (ISOTimezoneId != null) { stmtUpdateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, FullName); if (LastName != null) { stmtUpdateByPKey.setString(argIdx++, LastName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FirstName != null) { stmtUpdateByPKey.setString(argIdx++, FirstName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom != null) { stmtUpdateByPKey.setString(argIdx++, Custom); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom2 != null) { stmtUpdateByPKey.setString(argIdx++, Custom2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom3 != null) { stmtUpdateByPKey.setString(argIdx++, Custom3); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFAccContactBuff updatedBuff = unpackContactResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredContactListId(updatedBuff.getRequiredContactListId()); Buff.setOptionalISOTimezoneId(updatedBuff.getOptionalISOTimezoneId()); Buff.setRequiredFullName(updatedBuff.getRequiredFullName()); Buff.setOptionalLastName(updatedBuff.getOptionalLastName()); Buff.setOptionalFirstName(updatedBuff.getOptionalFirstName()); Buff.setOptionalCustom(updatedBuff.getOptionalCustom()); Buff.setOptionalCustom2(updatedBuff.getOptionalCustom2()); Buff.setOptionalCustom3(updatedBuff.getOptionalCustom3()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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.CFAccOracle.CFAccOracleContactTable.java
public void createContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) { final String S_ProcName = "createContact"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*www . j a v a 2 s.com*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long TenantId = Buff.getRequiredTenantId(); long ContactListId = Buff.getRequiredContactListId(); Short ISOTimezoneId = Buff.getOptionalISOTimezoneId(); String FullName = Buff.getRequiredFullName(); String LastName = Buff.getOptionalLastName(); String FirstName = Buff.getOptionalFirstName(); String Custom = Buff.getOptionalCustom(); String Custom2 = Buff.getOptionalCustom2(); String Custom3 = Buff.getOptionalCustom3(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_contact( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); 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++, "CTC"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setLong(argIdx++, ContactListId); if (ISOTimezoneId != null) { stmtCreateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtCreateByPKey.setString(argIdx++, FullName); if (LastName != null) { stmtCreateByPKey.setString(argIdx++, LastName); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FirstName != null) { stmtCreateByPKey.setString(argIdx++, FirstName); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom != null) { stmtCreateByPKey.setString(argIdx++, Custom); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom2 != null) { stmtCreateByPKey.setString(argIdx++, Custom2); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom3 != null) { stmtCreateByPKey.setString(argIdx++, Custom3); } 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_contact() did not return a result set"); } try { if (resultSet.next()) { CFAccContactBuff createdBuff = unpackContactResultSetToBuff(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.setRequiredContactId(createdBuff.getRequiredContactId()); Buff.setRequiredContactListId(createdBuff.getRequiredContactListId()); Buff.setOptionalISOTimezoneId(createdBuff.getOptionalISOTimezoneId()); Buff.setRequiredFullName(createdBuff.getRequiredFullName()); Buff.setOptionalLastName(createdBuff.getOptionalLastName()); Buff.setOptionalFirstName(createdBuff.getOptionalFirstName()); Buff.setOptionalCustom(createdBuff.getOptionalCustom()); Buff.setOptionalCustom2(createdBuff.getOptionalCustom2()); Buff.setOptionalCustom3(createdBuff.getOptionalCustom3()); 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_contact() 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.cfacc.v2_0.CFAccMSSql.CFAccMSSqlContactTable.java
public void updateContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) { final String S_ProcName = "updateContact"; ResultSet resultSet = null;//ww w . j a va2 s . co m try { long TenantId = Buff.getRequiredTenantId(); long ContactId = Buff.getRequiredContactId(); long ContactListId = Buff.getRequiredContactListId(); Short ISOTimezoneId = Buff.getOptionalISOTimezoneId(); String FullName = Buff.getRequiredFullName(); String LastName = Buff.getOptionalLastName(); String FirstName = Buff.getOptionalFirstName(); String Custom = Buff.getOptionalCustom(); String Custom2 = Buff.getOptionalCustom2(); String Custom3 = Buff.getOptionalCustom3(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "exec sp_update_contact ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CTC"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setLong(argIdx++, ContactListId); if (ISOTimezoneId != null) { stmtUpdateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, FullName); if (LastName != null) { stmtUpdateByPKey.setString(argIdx++, LastName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FirstName != null) { stmtUpdateByPKey.setString(argIdx++, FirstName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom != null) { stmtUpdateByPKey.setString(argIdx++, Custom); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom2 != null) { stmtUpdateByPKey.setString(argIdx++, Custom2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom3 != null) { stmtUpdateByPKey.setString(argIdx++, Custom3); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); stmtUpdateByPKey.execute(); boolean moreResults = true; resultSet = null; while (resultSet == null) { try { moreResults = stmtUpdateByPKey.getMoreResults(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (moreResults) { try { resultSet = stmtUpdateByPKey.getResultSet(); } catch (SQLException e) { } } else if (-1 == stmtUpdateByPKey.getUpdateCount()) { break; } } if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "resultSet"); } if (resultSet.next()) { CFAccContactBuff updatedBuff = unpackContactResultSetToBuff(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(updatedBuff.getRequiredContactListId()); Buff.setOptionalISOTimezoneId(updatedBuff.getOptionalISOTimezoneId()); Buff.setRequiredFullName(updatedBuff.getRequiredFullName()); Buff.setOptionalLastName(updatedBuff.getOptionalLastName()); Buff.setOptionalFirstName(updatedBuff.getOptionalFirstName()); Buff.setOptionalCustom(updatedBuff.getOptionalCustom()); Buff.setOptionalCustom2(updatedBuff.getOptionalCustom2()); Buff.setOptionalCustom3(updatedBuff.getOptionalCustom3()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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.CFAccOracle.CFAccOracleContactTable.java
public void updateContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) { final String S_ProcName = "updateContact"; ResultSet resultSet = null;/*from w ww . jav a 2s .c o m*/ Connection cnx = schema.getCnx(); CallableStatement stmtUpdateByPKey = null; List<CFAccContactBuff> buffList = new LinkedList<CFAccContactBuff>(); try { long TenantId = Buff.getRequiredTenantId(); long ContactId = Buff.getRequiredContactId(); long ContactListId = Buff.getRequiredContactListId(); Short ISOTimezoneId = Buff.getOptionalISOTimezoneId(); String FullName = Buff.getRequiredFullName(); String LastName = Buff.getOptionalLastName(); String FirstName = Buff.getOptionalFirstName(); String Custom = Buff.getOptionalCustom(); String Custom2 = Buff.getOptionalCustom2(); String Custom3 = Buff.getOptionalCustom3(); int Revision = Buff.getRequiredRevision(); stmtUpdateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".upd_contact( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;"); int argIdx = 1; stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CTC"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setLong(argIdx++, ContactListId); if (ISOTimezoneId != null) { stmtUpdateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, FullName); if (LastName != null) { stmtUpdateByPKey.setString(argIdx++, LastName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (FirstName != null) { stmtUpdateByPKey.setString(argIdx++, FirstName); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom != null) { stmtUpdateByPKey.setString(argIdx++, Custom); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom2 != null) { stmtUpdateByPKey.setString(argIdx++, Custom2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (Custom3 != null) { stmtUpdateByPKey.setString(argIdx++, Custom3); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); stmtUpdateByPKey.execute(); resultSet = (ResultSet) stmtUpdateByPKey.getObject(1); if (resultSet != null) { try { if (resultSet.next()) { CFAccContactBuff updatedBuff = unpackContactResultSetToBuff(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(updatedBuff.getRequiredContactListId()); Buff.setOptionalISOTimezoneId(updatedBuff.getOptionalISOTimezoneId()); Buff.setRequiredFullName(updatedBuff.getRequiredFullName()); Buff.setOptionalLastName(updatedBuff.getOptionalLastName()); Buff.setOptionalFirstName(updatedBuff.getOptionalFirstName()); Buff.setOptionalCustom(updatedBuff.getOptionalCustom()); Buff.setOptionalCustom2(updatedBuff.getOptionalCustom2()); Buff.setOptionalCustom3(updatedBuff.getOptionalCustom3()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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, "upd_contact() did not return a valid result cursor"); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "upd_contact() did not return a result cursor"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtUpdateByPKey != null) { try { stmtUpdateByPKey.close(); } catch (SQLException e) { } stmtUpdateByPKey = null; } } }
From source file:org.energy_home.jemma.ah.internal.greenathome.GreenathomeAppliance.java
public void notifyAttributeValue(String clusterName, String attributeName, IAttributeValue attributeValue, IEndPointRequestContext endPointRequestContext) throws ServiceClusterException, ApplianceException { synchronized (lockGatH) { if (logEnabled) log.debug("arrived attribute " + attributeName + " with value " + attributeValue.getValue().toString()); if (attributeName.equals(SimpleMeteringServer.ATTR_IstantaneousDemand_NAME)) { IAppliance peerAppliance = endPointRequestContext.getPeerEndPoint().getAppliance(); Short demandFormatting = (Short) demandFormattings.get(peerAppliance.getPid()); if (demandFormatting == null) { log.fatal("demand formatting not available for appliance " + peerAppliance.getPid()); return; }//from w w w . j av a 2s . c o m double power = decodeFormatting(((Number) attributeValue.getValue()).longValue(), demandFormatting.shortValue()); this.istantaneousDemands.put(peerAppliance.getPid(), new Double(power)); log.debug("calculated on appliance " + peerAppliance.getPid() + " power " + power); } else if (attributeName.equals(SimpleMetering4NoksServer.ATTR_Power_NAME)) { IAppliance peerAppliance = endPointRequestContext.getPeerEndPoint().getAppliance(); double power = ((Number) attributeValue.getValue()).longValue(); this.istantaneousDemands.put(peerAppliance.getPid(), new Double(power)); } else if (attributeName.equals(OccupancySensingServer.ATTR_Occupancy_NAME)) { IAppliance peerAppliance = endPointRequestContext.getPeerEndPoint().getAppliance(); if (logEnabled) log.debug("arrived attribute " + attributeName + " with value " + attributeValue.getValue().toString()); this.occupancySensing.put(peerAppliance.getPid(), attributeValue); } else if (attributeName.equals(TemperatureMeasurementServer.ATTR_MeasuredValue_NAME)) { IAppliance peerAppliance = endPointRequestContext.getPeerEndPoint().getAppliance(); if (logEnabled) log.debug("arrived attribute " + attributeName + " with value " + attributeValue.getValue().toString()); this.measuredValues.put(peerAppliance.getPid(), attributeValue); } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountEntryTable.java
public CFAccAccountEntryBuff[] readBuffByDrCcyIdx(CFAccAuthorization Authorization, Short DebitCurrencyId) { final String S_ProcName = "readBuffByDrCcyIdx"; ResultSet resultSet = null;//from ww w . j a v a 2 s . c o m try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByDrCcyIdx == null) { stmtReadBuffByDrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (DebitCurrencyId != null) { stmtReadBuffByDrCcyIdx.setShort(argIdx++, DebitCurrencyId.shortValue()); } else { stmtReadBuffByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByDrCcyIdx.executeQuery(); List<CFAccAccountEntryBuff> buffList = new LinkedList<CFAccAccountEntryBuff>(); while (resultSet.next()) { CFAccAccountEntryBuff buff = unpackAccountEntryResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountEntryBuff[] retBuff = new CFAccAccountEntryBuff[buffList.size()]; Iterator<CFAccAccountEntryBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } 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.CFAccDb2LUWAccountEntryTable.java
public void deleteAccountEntryByDrCcyIdx(CFAccAuthorization Authorization, Short argDebitCurrencyId) { final String S_ProcName = "deleteAccountEntryByDrCcyIdx"; ResultSet resultSet = null;/* w w w . j a va2 s. c om*/ try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByDrCcyIdx == null) { stmtDeleteByDrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argDebitCurrencyId != null) { stmtDeleteByDrCcyIdx.setShort(argIdx++, argDebitCurrencyId.shortValue()); } else { stmtDeleteByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtDeleteByDrCcyIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } 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.CFAccDb2LUWAccountEntryTable.java
public CFAccAccountEntryBuff[] readBuffByCrCcyIdx(CFAccAuthorization Authorization, Short CreditCurrencyId) { final String S_ProcName = "readBuffByCrCcyIdx"; ResultSet resultSet = null;// w w w .j a v a2s .c o m try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_ac_entry_by_crccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCrCcyIdx == null) { stmtReadBuffByCrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (CreditCurrencyId != null) { stmtReadBuffByCrCcyIdx.setShort(argIdx++, CreditCurrencyId.shortValue()); } else { stmtReadBuffByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByCrCcyIdx.executeQuery(); List<CFAccAccountEntryBuff> buffList = new LinkedList<CFAccAccountEntryBuff>(); while (resultSet.next()) { CFAccAccountEntryBuff buff = unpackAccountEntryResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountEntryBuff[] retBuff = new CFAccAccountEntryBuff[buffList.size()]; Iterator<CFAccAccountEntryBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }