List of usage examples for java.sql Types SMALLINT
int SMALLINT
To view the source code for java.sql Types SMALLINT.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type SMALLINT
.
From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatUtilities.java
/** * Resolve a database-specific type to HCat data type. Largely follows Sqoop's * hive translation./* w w w . ja v a 2 s.c o m*/ * @param sqlType * sql type * @return hcat type */ public static String toHCatType(int sqlType) { switch (sqlType) { // Ideally TINYINT and SMALLINT should be mapped to their // HCat equivalents tinyint and smallint respectively // But the Sqoop Java type conversion has them mapped to Integer // Even though the referenced Java doc clearly recommends otherwise. // Changing this now can cause many of the sequence file usages to // break as value class implementations will change. So, we // just use the same behavior here. case Types.SMALLINT: case Types.TINYINT: case Types.INTEGER: return "int"; case Types.VARCHAR: return "varchar"; case Types.CHAR: return "char"; case Types.LONGVARCHAR: case Types.NVARCHAR: case Types.NCHAR: case Types.LONGNVARCHAR: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: case Types.CLOB: return "string"; case Types.FLOAT: case Types.REAL: return "float"; case Types.NUMERIC: case Types.DECIMAL: return "decimal"; case Types.DOUBLE: return "double"; case Types.BIT: case Types.BOOLEAN: return "boolean"; case Types.BIGINT: return "bigint"; case Types.BINARY: case Types.VARBINARY: case Types.BLOB: case Types.LONGVARBINARY: return "binary"; default: throw new IllegalArgumentException("Cannot convert SQL type to HCatalog type " + sqlType); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlContactURLTable.java
public void updateContactURL(CFAccAuthorization Authorization, CFAccContactURLBuff Buff) { final String S_ProcName = "updateContactURL"; ResultSet resultSet = null;//from w w w. j av a 2s .c o m try { long TenantId = Buff.getRequiredTenantId(); long ContactURLId = Buff.getRequiredContactURLId(); long ContactId = Buff.getRequiredContactId(); Short URLProtocolId = Buff.getOptionalURLProtocolId(); String Name = Buff.getRequiredName(); String URL = Buff.getRequiredURL(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_update_ctcurl( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "CURL"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactURLId); stmtUpdateByPKey.setLong(argIdx++, ContactId); if (URLProtocolId != null) { stmtUpdateByPKey.setShort(argIdx++, URLProtocolId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, Name); stmtUpdateByPKey.setString(argIdx++, URL); stmtUpdateByPKey.setInt(argIdx++, Revision); try { resultSet = stmtUpdateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFAccContactURLBuff updatedBuff = unpackContactURLResultSetToBuff(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.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setOptionalURLProtocolId(updatedBuff.getOptionalURLProtocolId()); Buff.setRequiredName(updatedBuff.getRequiredName()); Buff.setRequiredURL(updatedBuff.getRequiredURL()); 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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWContactTable.java
public void updateContact(CFCrmAuthorization Authorization, CFCrmContactBuff Buff) { final String S_ProcName = "updateContact"; if ("CTC".equals(Buff.getClassCode()) && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateContact"))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- User not part of TSecGroup UpdateContact"); }// w ww .j av a2s . c o m ResultSet resultSet = null; 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(); final String sql = "CALL 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()) { 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:org.jumpmind.symmetric.db.AbstractTriggerTemplate.java
protected String buildKeyVariablesDeclare(Column[] columns, String prefix) { String text = ""; for (int i = 0; i < columns.length; i++) { text += "declare @" + prefix + "pk" + i + " "; switch (columns[i].getMappedTypeCode()) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: text += "bigint\n"; break; case Types.NUMERIC: case Types.DECIMAL: text += "decimal\n"; break; case Types.FLOAT: case Types.REAL: case Types.DOUBLE: text += "float\n"; break; case Types.CHAR: case Types.VARCHAR: case ColumnTypes.NVARCHAR: case ColumnTypes.LONGNVARCHAR: case Types.LONGVARCHAR: text += "varchar(1000)\n"; break; case Types.DATE: text += "date\n"; break; case Types.TIME: text += "time\n"; break; case Types.TIMESTAMP: text += "datetime\n"; break; case Types.BOOLEAN: case Types.BIT: text += "bit\n"; break; case Types.CLOB: text += "varchar(max)\n"; break; case Types.BLOB: case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: case -10: // SQL-Server ntext binary type text += "varbinary(max)\n"; break; case Types.OTHER: text += "varbinary(max)\n"; break; default://from w w w . j av a 2s . c om if (columns[i].getJdbcTypeName() != null && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) { text += "interval"; break; } throw new NotImplementedException(columns[i] + " is of type " + columns[i].getMappedType()); } } return text; }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmDb2LUW.CFCrmDb2LUWAddressTable.java
public void updateAddress(CFCrmAuthorization Authorization, CFCrmAddressBuff Buff) { final String S_ProcName = "updateAddress"; if ("ADR".equals(Buff.getClassCode()) && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateAddress"))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- User not part of TSecGroup UpdateAddress"); }/*from ww w . ja va 2 s . co m*/ ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); long AddressId = Buff.getRequiredAddressId(); long ContactId = Buff.getRequiredContactId(); String Description = Buff.getRequiredDescription(); String AddrLine1 = Buff.getOptionalAddrLine1(); String AddrLine2 = Buff.getOptionalAddrLine2(); String City = Buff.getOptionalCity(); String State = Buff.getOptionalState(); Short CountryId = Buff.getOptionalCountryId(); String Zip = Buff.getOptionalZip(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_address( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "ADR"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, AddressId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setString(argIdx++, Description); if (AddrLine1 != null) { stmtUpdateByPKey.setString(argIdx++, AddrLine1); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (AddrLine2 != null) { stmtUpdateByPKey.setString(argIdx++, AddrLine2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (City != null) { stmtUpdateByPKey.setString(argIdx++, City); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (State != null) { stmtUpdateByPKey.setString(argIdx++, State); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (CountryId != null) { stmtUpdateByPKey.setShort(argIdx++, CountryId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } if (Zip != null) { stmtUpdateByPKey.setString(argIdx++, Zip); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFCrmAddressBuff updatedBuff = unpackAddressResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setRequiredDescription(updatedBuff.getRequiredDescription()); Buff.setOptionalAddrLine1(updatedBuff.getOptionalAddrLine1()); Buff.setOptionalAddrLine2(updatedBuff.getOptionalAddrLine2()); Buff.setOptionalCity(updatedBuff.getOptionalCity()); Buff.setOptionalState(updatedBuff.getOptionalState()); Buff.setOptionalCountryId(updatedBuff.getOptionalCountryId()); Buff.setOptionalZip(updatedBuff.getOptionalZip()); 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;/* ww w.java2 s.c om*/ 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.CFAccDb2LUW.CFAccDb2LUWContactTable.java
public void updateContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) { final String S_ProcName = "updateContact"; if ("CTC".equals(Buff.getClassCode()) && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateContact"))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- User not part of TSecGroup UpdateContact"); }// www. j a v a 2 s. c o m ResultSet resultSet = null; 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(); final String sql = "CALL 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()) { 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.CFAccPgSqlAddressTable.java
public void updateAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) { final String S_ProcName = "updateAddress"; ResultSet resultSet = null;//w w w . jav a 2 s . com try { long TenantId = Buff.getRequiredTenantId(); long AddressId = Buff.getRequiredAddressId(); long ContactId = Buff.getRequiredContactId(); String Description = Buff.getRequiredDescription(); String AddrLine1 = Buff.getOptionalAddrLine1(); String AddrLine2 = Buff.getOptionalAddrLine2(); String City = Buff.getOptionalCity(); String State = Buff.getOptionalState(); Short CountryId = Buff.getOptionalCountryId(); String Zip = Buff.getOptionalZip(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_update_address( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "ADR"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, AddressId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setString(argIdx++, Description); if (AddrLine1 != null) { stmtUpdateByPKey.setString(argIdx++, AddrLine1); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (AddrLine2 != null) { stmtUpdateByPKey.setString(argIdx++, AddrLine2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (City != null) { stmtUpdateByPKey.setString(argIdx++, City); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (State != null) { stmtUpdateByPKey.setString(argIdx++, State); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (CountryId != null) { stmtUpdateByPKey.setShort(argIdx++, CountryId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } if (Zip != null) { stmtUpdateByPKey.setString(argIdx++, Zip); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFAccAddressBuff updatedBuff = unpackAddressResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setRequiredDescription(updatedBuff.getRequiredDescription()); Buff.setOptionalAddrLine1(updatedBuff.getOptionalAddrLine1()); Buff.setOptionalAddrLine2(updatedBuff.getOptionalAddrLine2()); Buff.setOptionalCity(updatedBuff.getOptionalCity()); Buff.setOptionalState(updatedBuff.getOptionalState()); Buff.setOptionalCountryId(updatedBuff.getOptionalCountryId()); Buff.setOptionalZip(updatedBuff.getOptionalZip()); 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.CFAccDb2LUW.CFAccDb2LUWAddressTable.java
public void updateAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) { final String S_ProcName = "updateAddress"; if ("ADR".equals(Buff.getClassCode()) && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateAddress"))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- User not part of TSecGroup UpdateAddress"); }// www. j a v a 2s. c o m ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); long AddressId = Buff.getRequiredAddressId(); long ContactId = Buff.getRequiredContactId(); String Description = Buff.getRequiredDescription(); String AddrLine1 = Buff.getOptionalAddrLine1(); String AddrLine2 = Buff.getOptionalAddrLine2(); String City = Buff.getOptionalCity(); String State = Buff.getOptionalState(); Short CountryId = Buff.getOptionalCountryId(); String Zip = Buff.getOptionalZip(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_address( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "ADR"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, AddressId); stmtUpdateByPKey.setLong(argIdx++, ContactId); stmtUpdateByPKey.setString(argIdx++, Description); if (AddrLine1 != null) { stmtUpdateByPKey.setString(argIdx++, AddrLine1); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (AddrLine2 != null) { stmtUpdateByPKey.setString(argIdx++, AddrLine2); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (City != null) { stmtUpdateByPKey.setString(argIdx++, City); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (State != null) { stmtUpdateByPKey.setString(argIdx++, State); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (CountryId != null) { stmtUpdateByPKey.setShort(argIdx++, CountryId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } if (Zip != null) { stmtUpdateByPKey.setString(argIdx++, Zip); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFAccAddressBuff updatedBuff = unpackAddressResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setRequiredDescription(updatedBuff.getRequiredDescription()); Buff.setOptionalAddrLine1(updatedBuff.getOptionalAddrLine1()); Buff.setOptionalAddrLine2(updatedBuff.getOptionalAddrLine2()); Buff.setOptionalCity(updatedBuff.getOptionalCity()); Buff.setOptionalState(updatedBuff.getOptionalState()); Buff.setOptionalCountryId(updatedBuff.getOptionalCountryId()); Buff.setOptionalZip(updatedBuff.getOptionalZip()); 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.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlContactTable.java
public void updateContact(CFCrmAuthorization Authorization, CFCrmContactBuff Buff) { final String S_ProcName = "updateContact"; ResultSet resultSet = null;//from w ww . j av a 2s . 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()) { 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; } } }