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:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstMSSql.CFAstMSSqlISOLanguageTable.java
public CFAstISOLanguageBuff[] readBuffByCountryIdx(CFAstAuthorization Authorization, Short ISOCountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;//from ww w . j av a2 s. c om try { Connection cnx = schema.getCnx(); String sql = "{ call sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByCountryIdx.executeQuery(); List<CFAstISOLanguageBuff> buffList = new LinkedList<CFAstISOLanguageBuff>(); if (resultSet != null) { while (resultSet.next()) { CFAstISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } } int idx = 0; CFAstISOLanguageBuff[] retBuff = new CFAstISOLanguageBuff[buffList.size()]; Iterator<CFAstISOLanguageBuff> 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.CFAccMSSql.CFAccMSSqlISOLanguageTable.java
public CFAccISOLanguageBuff[] readBuffByCountryIdx(CFAccAuthorization Authorization, Short ISOCountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;/* ww w.j av a2 s . c o m*/ try { Connection cnx = schema.getCnx(); String sql = "{ call sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByCountryIdx.executeQuery(); List<CFAccISOLanguageBuff> buffList = new LinkedList<CFAccISOLanguageBuff>(); if (resultSet != null) { while (resultSet.next()) { CFAccISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } } int idx = 0; CFAccISOLanguageBuff[] retBuff = new CFAccISOLanguageBuff[buffList.size()]; Iterator<CFAccISOLanguageBuff> 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.cffreeswitch.v2_1.CFFswMySql.CFFswMySqlISOLanguageTable.java
public CFFswISOLanguageBuff[] readBuffByCountryIdx(CFFswAuthorization Authorization, Short ISOCountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;/* w w w .j a v a2s . co m*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } try { resultSet = stmtReadBuffByCountryIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFFswISOLanguageBuff> buffList = new LinkedList<CFFswISOLanguageBuff>(); while ((resultSet != null) && resultSet.next()) { CFFswISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFFswISOLanguageBuff[] retBuff = new CFFswISOLanguageBuff[buffList.size()]; Iterator<CFFswISOLanguageBuff> 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.cfasterisk.v2_0.CFAstMySql.CFAstMySqlISOLanguageTable.java
public CFAstISOLanguageBuff[] readBuffByCountryIdx(CFAstAuthorization Authorization, Short ISOCountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;// w ww . j a va2 s .co m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } try { resultSet = stmtReadBuffByCountryIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFAstISOLanguageBuff> buffList = new LinkedList<CFAstISOLanguageBuff>(); while ((resultSet != null) && resultSet.next()) { CFAstISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAstISOLanguageBuff[] retBuff = new CFAstISOLanguageBuff[buffList.size()]; Iterator<CFAstISOLanguageBuff> 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.cfasterisk.v2_1.CFAstMySql.CFAstMySqlISOLanguageTable.java
public CFAstISOLanguageBuff[] readBuffByCountryIdx(CFAstAuthorization Authorization, Short ISOCountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;/* w w w . java 2 s. c o m*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } try { resultSet = stmtReadBuffByCountryIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFAstISOLanguageBuff> buffList = new LinkedList<CFAstISOLanguageBuff>(); while ((resultSet != null) && resultSet.next()) { CFAstISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAstISOLanguageBuff[] retBuff = new CFAstISOLanguageBuff[buffList.size()]; Iterator<CFAstISOLanguageBuff> 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.CFAccMySql.CFAccMySqlISOLanguageTable.java
public CFAccISOLanguageBuff[] readBuffByCountryIdx(CFAccAuthorization Authorization, Short ISOCountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;//from ww w . jav a 2s . co m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } try { resultSet = stmtReadBuffByCountryIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFAccISOLanguageBuff> buffList = new LinkedList<CFAccISOLanguageBuff>(); while ((resultSet != null) && resultSet.next()) { CFAccISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccISOLanguageBuff[] retBuff = new CFAccISOLanguageBuff[buffList.size()]; Iterator<CFAccISOLanguageBuff> 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.cfensyntax.v2_2.CFEnSyntaxMSSql.CFEnSyntaxMSSqlISOLanguageTable.java
public CFEnSyntaxISOLanguageBuff[] readBuffByCountryIdx(CFEnSyntaxAuthorization Authorization, Short ISOCountryId) {//from w w w .jav a2 s . c om final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "{ call sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByCountryIdx.executeQuery(); List<CFEnSyntaxISOLanguageBuff> buffList = new LinkedList<CFEnSyntaxISOLanguageBuff>(); if (resultSet != null) { while (resultSet.next()) { CFEnSyntaxISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } } int idx = 0; CFEnSyntaxISOLanguageBuff[] retBuff = new CFEnSyntaxISOLanguageBuff[buffList.size()]; Iterator<CFEnSyntaxISOLanguageBuff> 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.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlISOLanguageTable.java
public CFEnSyntaxISOLanguageBuff[] readBuffByCountryIdx(CFEnSyntaxAuthorization Authorization, Short ISOCountryId) {//from www . ja va 2s. c o m final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_iso_lang_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOCountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, ISOCountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } try { resultSet = stmtReadBuffByCountryIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFEnSyntaxISOLanguageBuff> buffList = new LinkedList<CFEnSyntaxISOLanguageBuff>(); while ((resultSet != null) && resultSet.next()) { CFEnSyntaxISOLanguageBuff buff = unpackISOLanguageResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFEnSyntaxISOLanguageBuff[] retBuff = new CFEnSyntaxISOLanguageBuff[buffList.size()]; Iterator<CFEnSyntaxISOLanguageBuff> 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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWContactURLTable.java
public CFCrmContactURLBuff[] readBuffByProtocolIdx(CFCrmAuthorization Authorization, Short URLProtocolId) { final String S_ProcName = "readBuffByProtocolIdx"; ResultSet resultSet = null;// ww w.j av a2 s . c o m try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_ctcurl_by_protocolidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByProtocolIdx == null) { stmtReadBuffByProtocolIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByProtocolIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByProtocolIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (URLProtocolId != null) { stmtReadBuffByProtocolIdx.setShort(argIdx++, URLProtocolId.shortValue()); } else { stmtReadBuffByProtocolIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByProtocolIdx.executeQuery(); List<CFCrmContactURLBuff> buffList = new LinkedList<CFCrmContactURLBuff>(); while (resultSet.next()) { CFCrmContactURLBuff buff = unpackContactURLResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFCrmContactURLBuff[] retBuff = new CFCrmContactURLBuff[buffList.size()]; Iterator<CFCrmContactURLBuff> 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:com.funambol.foundation.items.dao.PIMContactDAO.java
/** * Adds a contact. If necessary, a new ID is generated and set in the * ContactWrapper.//from ww w . j av a 2 s.com * * @param cw as a ContactWrapper object, usually without an ID set. * @throws DAOException * * @see ContactWrapper */ public void addItem(ContactWrapper cw) throws DAOException { if (log.isTraceEnabled()) { log.trace("Storing a contact item..."); } Connection con = null; PreparedStatement ps = null; long id = 0; int type = 0; PersonalDetail personalDetail = null; BusinessDetail businessDetail = null; Address homeAddressBook = null; Address workAddressBook = null; Address otherAddressBook = null; Name name = null; Phone phone = null; Email email = null; WebPage webPage = null; List<WebPage> webPages = new ArrayList<WebPage>(); List<Email> emails = new ArrayList<Email>(); List<Phone> phones = new ArrayList<Phone>(); List<String[]> labels = new ArrayList<String[]>(); String webPageType = null; Short importance = null; Short sensitivity = null; String mileage = null; String subject = null; String folder = null; String anniversary = null; String firstName = null; String middleName = null; String lastName = null; String displayName = null; String birthday = null; String categories = null; String gender = null; String hobbies = null; String initials = null; String languages = null; String nickName = null; String spouse = null; String suffix = null; String assistant = null; String officeLocation = null; String company = null; String companies = null; String department = null; String manager = null; String role = null; String children = null; String salutation = null; String sId = null; Timestamp lastUpdate = cw.getLastUpdate(); if (lastUpdate == null) { lastUpdate = new Timestamp(System.currentTimeMillis()); } try { // Looks up the data source when the first connection is created con = getUserDataSource().getRoutedConnection(userId); sId = cw.getId(); if (sId == null) { // ...as it should be sId = getNextID(); cw.setId(sId); } id = Long.parseLong(sId); Contact c = cw.getContact(); personalDetail = c.getPersonalDetail(); businessDetail = c.getBusinessDetail(); name = c.getName(); if (personalDetail != null) { homeAddressBook = personalDetail.getAddress(); otherAddressBook = personalDetail.getOtherAddress(); webPages.addAll(personalDetail.getWebPages()); emails.addAll(personalDetail.getEmails()); phones.addAll(personalDetail.getPhones()); } if (businessDetail != null) { workAddressBook = businessDetail.getAddress(); webPages.addAll(businessDetail.getWebPages()); emails.addAll(businessDetail.getEmails()); phones.addAll(businessDetail.getPhones()); companies = businessDetail.getCompanies(); } importance = c.getImportance(); sensitivity = c.getSensitivity(); mileage = c.getMileage(); subject = c.getSubject(); languages = c.getLanguages(); categories = Property.stringFrom(c.getCategories()); folder = c.getFolder(); if (personalDetail != null) { anniversary = personalDetail.getAnniversary(); birthday = personalDetail.getBirthday(); children = personalDetail.getChildren(); spouse = personalDetail.getSpouse(); hobbies = personalDetail.getHobbies(); gender = personalDetail.getGender(); } if (businessDetail != null) { assistant = businessDetail.getAssistant(); manager = businessDetail.getManager(); officeLocation = businessDetail.getOfficeLocation(); company = Property.stringFrom(businessDetail.getCompany()); department = Property.stringFrom(businessDetail.getDepartment()); role = Property.stringFrom(businessDetail.getRole()); } if (name != null) { firstName = Property.stringFrom(name.getFirstName()); middleName = Property.stringFrom(name.getMiddleName()); lastName = Property.stringFrom(name.getLastName()); displayName = Property.stringFrom(name.getDisplayName()); initials = Property.stringFrom(name.getInitials()); nickName = Property.stringFrom(name.getNickname()); suffix = Property.stringFrom(name.getSuffix()); salutation = Property.stringFrom(name.getSalutation()); } ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_CONTACT); // // GENERAL // if (log.isTraceEnabled()) { log.trace("Preparing statement with ID " + id); } ps.setLong(1, id); if (log.isTraceEnabled()) { log.trace("Preparing statement with user ID " + userId); } ps.setString(2, userId); ps.setLong(3, lastUpdate.getTime()); ps.setString(4, String.valueOf(Def.PIM_STATE_NEW)); boolean hasPhoto = false; Photo photo = personalDetail.getPhotoObject(); if (photo != null && (photo.getImage() != null || photo.getUrl() != null)) { hasPhoto = true; ps.setShort(5, photo.getImage() != null ? ContactWrapper.PHOTO_IMAGE : ContactWrapper.PHOTO_URL); } else if (photo != null) { ps.setShort(5, ContactWrapper.EMPTY_PHOTO); } else { ps.setNull(5, Types.SMALLINT); } // // CONTACT DETAILS // if (importance != null) { ps.setShort(6, importance.shortValue()); } else { ps.setNull(6, Types.SMALLINT); } if (sensitivity != null) { ps.setShort(7, sensitivity.shortValue()); } else { ps.setNull(7, Types.SMALLINT); } ps.setString(8, StringUtils.left(subject, SQL_SUBJECT_DIM)); ps.setString(9, StringUtils.left(folder, SQL_FOLDER_DIM)); // // PERSONAL DETAILS // ps.setString(10, StringUtils.left(anniversary, SQL_ANNIVERSARY_DIM)); ps.setString(11, StringUtils.left(firstName, SQL_FIRSTNAME_DIM)); ps.setString(12, StringUtils.left(middleName, SQL_MIDDLENAME_DIM)); ps.setString(13, StringUtils.left(lastName, SQL_LASTNAME_DIM)); ps.setString(14, StringUtils.left(displayName, SQL_DISPLAYNAME_DIM)); ps.setString(15, StringUtils.left(birthday, SQL_BIRTHDAY_DIM)); if (c.getNotes() != null && c.getNotes().size() > 0) { String noteValue = ((Note) c.getNotes().get(0)).getPropertyValueAsString(); ps.setString(16, StringUtils.left(noteValue, SQL_NOTE_DIM)); } else { ps.setString(16, null); } ps.setString(17, StringUtils.left(categories, SQL_CATEGORIES_DIM)); ps.setString(18, StringUtils.left(children, SQL_CHILDREN_DIM)); ps.setString(19, StringUtils.left(hobbies, SQL_HOBBIES_DIM)); ps.setString(20, StringUtils.left(initials, SQL_INITIALS_DIM)); ps.setString(21, StringUtils.left(languages, SQL_LANGUAGES_DIM)); ps.setString(22, StringUtils.left(nickName, SQL_NICKNAME_DIM)); ps.setString(23, StringUtils.left(spouse, SQL_SPOUSE_DIM)); ps.setString(24, StringUtils.left(suffix, SQL_SUFFIX_DIM)); ps.setString(25, StringUtils.left(salutation, SQL_SALUTATION_DIM)); // // BUSINESS DETAILS // ps.setString(26, StringUtils.left(assistant, SQL_ASSISTANT_DIM)); ps.setString(27, StringUtils.left(company, SQL_COMPANY_DIM)); ps.setString(28, StringUtils.left(department, SQL_DEPARTMENT_DIM)); if (businessDetail.getTitles() != null && businessDetail.getTitles().size() > 0) { String titleValue = ((Title) businessDetail.getTitles().get(0)).getPropertyValueAsString(); ps.setString(29, StringUtils.left(titleValue, SQL_TITLE_DIM)); } else { ps.setString(29, null); } ps.setString(30, StringUtils.left(manager, SQL_MANAGER_DIM)); if (mileage != null && mileage.length() > SQL_MILEAGE_DIM) { mileage = mileage.substring(0, SQL_MILEAGE_DIM); } ps.setString(31, StringUtils.left(mileage, SQL_MILEAGE_DIM)); ps.setString(32, StringUtils.left(officeLocation, SQL_OFFICELOCATION_DIM)); ps.setString(33, StringUtils.left(role, SQL_ROLE_DIM)); ps.setString(34, StringUtils.left(companies, SQL_COMPANIES_DIM)); ps.setString(35, StringUtils.left(gender, SQL_GENDER_DIM)); ps.executeUpdate(); DBTools.close(null, ps, null); // // emails // if (!emails.isEmpty()) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_CONTACT_ITEM); for (int i = 0, l = emails.size(); i < l; i++) { email = emails.get(i); type = getContactEmailItemTypeFromEmailPropertyType(email.getEmailType()); // Unknown property: saves nothing if (TYPE_UNDEFINED == type) continue; String emailValue = email.getPropertyValueAsString(); if (emailValue != null && emailValue.length() != 0) { if (emailValue.length() > SQL_EMAIL_DIM) { emailValue = emailValue.substring(0, SQL_EMAIL_DIM); } ps.setLong(1, id); ps.setInt(2, type); ps.setString(3, emailValue); ps.executeUpdate(); } } DBTools.close(null, ps, null); } // // phones // if (!phones.isEmpty()) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_CONTACT_ITEM); for (int i = 0, l = phones.size(); i < l; i++) { phone = phones.get(i); type = getContactPhoneItemTypeFromPhonePropertyType(phone.getPhoneType()); // Unknown property: saves nothing if (TYPE_UNDEFINED == type) continue; String phoneValue = phone.getPropertyValueAsString(); if (phoneValue != null && phoneValue.length() != 0) { if (phoneValue.length() > SQL_PHONE_DIM) { phoneValue = phoneValue.substring(0, SQL_PHONE_DIM); } ps.setLong(1, id); ps.setInt(2, type); ps.setString(3, phoneValue); ps.executeUpdate(); } } DBTools.close(null, ps, null); } // // webPages // if (!webPages.isEmpty()) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_CONTACT_ITEM); for (int i = 0, l = webPages.size(); i < l; i++) { webPage = webPages.get(i); webPageType = webPage.getWebPageType(); if ((FIELD_WEB_PAGE).equals(webPageType)) { type = TYPE_WEB_PAGE; } else if ((FIELD_HOME_WEB_PAGE).equals(webPageType)) { type = TYPE_HOME_WEB_PAGE; } else if ((FIELD_BUSINESS_WEB_PAGE).equals(webPageType)) { type = TYPE_BUSINESS_WEB_PAGE; } else { // // Unknown property: saves nothing // continue; } String webPageValue = webPage.getPropertyValueAsString(); if (webPageValue != null && webPageValue.length() != 0) { if (webPageValue.length() > SQL_WEBPAGE_DIM) { webPageValue = webPageValue.substring(0, SQL_WEBPAGE_DIM); } ps.setLong(1, id); ps.setInt(2, type); ps.setString(3, webPageValue); ps.executeUpdate(); } } DBTools.close(null, ps, null); } if (homeAddressBook != null) { String homeStreet = Property.stringFrom(homeAddressBook.getStreet()); String homeCity = Property.stringFrom(homeAddressBook.getCity()); String homePostalCode = Property.stringFrom(homeAddressBook.getPostalCode()); String homeState = Property.stringFrom(homeAddressBook.getState()); String homeCountry = Property.stringFrom(homeAddressBook.getCountry()); String homePostalOfficeAddress = Property.stringFrom(homeAddressBook.getPostOfficeAddress()); String homeExtendedAddress = Property.stringFrom(homeAddressBook.getExtendedAddress()); String homeLabel = Property.stringFrom(homeAddressBook.getLabel()); if (homeLabel != null) { String[] label = { homeLabel, FIELD_HOME_LABEL }; labels.add(label); } String[] homeAddressFields = { homeStreet, homeCity, homePostalCode, homeCountry, homeState, homePostalOfficeAddress, homeExtendedAddress }; if (!hasOnlyEmptyOrNullContent(homeAddressFields)) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_ADDRESS); ps.setLong(1, id); ps.setInt(2, ADDRESS_TYPE_HOME); ps.setString(3, replaceNewLine(StringUtils.left(homeStreet, SQL_STREET_DIM))); ps.setString(4, StringUtils.left(homeCity, SQL_CITY_DIM)); ps.setString(5, StringUtils.left(homeState, SQL_STATE_DIM)); ps.setString(6, StringUtils.left(homePostalCode, SQL_POSTALCODE_DIM)); ps.setString(7, StringUtils.left(homeCountry, SQL_COUNTRY_DIM)); ps.setString(8, StringUtils.left(homePostalOfficeAddress, SQL_POSTALOFFICEADDRESS_DIM)); ps.setString(9, StringUtils.left(homeExtendedAddress, SQL_EXTENDEDADDRESS_DIM)); ps.executeUpdate(); DBTools.close(null, ps, null); } } if (otherAddressBook != null) { String otherStreet = Property.stringFrom(otherAddressBook.getStreet()); String otherCity = Property.stringFrom(otherAddressBook.getCity()); String otherPostalCode = Property.stringFrom(otherAddressBook.getPostalCode()); String otherState = Property.stringFrom(otherAddressBook.getState()); String otherCountry = Property.stringFrom(otherAddressBook.getCountry()); String otherPostalOfficeAddress = Property.stringFrom(otherAddressBook.getPostOfficeAddress()); String otherExtendedAddress = Property.stringFrom(otherAddressBook.getExtendedAddress()); String otherLabel = Property.stringFrom(otherAddressBook.getLabel()); if (otherLabel != null) { String[] label = { otherLabel, FIELD_OTHER_LABEL }; labels.add(label); } String[] otherAddressFields = { otherStreet, otherCity, otherPostalCode, otherCountry, otherState, otherPostalOfficeAddress, otherExtendedAddress }; if (!hasOnlyEmptyOrNullContent(otherAddressFields)) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_ADDRESS); ps.setLong(1, id); ps.setInt(2, ADDRESS_TYPE_OTHER); ps.setString(3, replaceNewLine(StringUtils.left(otherStreet, SQL_STREET_DIM))); ps.setString(4, StringUtils.left(otherCity, SQL_CITY_DIM)); ps.setString(5, StringUtils.left(otherState, SQL_STATE_DIM)); ps.setString(6, StringUtils.left(otherPostalCode, SQL_POSTALCODE_DIM)); ps.setString(7, StringUtils.left(otherCountry, SQL_COUNTRY_DIM)); ps.setString(8, StringUtils.left(otherPostalOfficeAddress, SQL_POSTALOFFICEADDRESS_DIM)); ps.setString(9, StringUtils.left(otherExtendedAddress, SQL_EXTENDEDADDRESS_DIM)); ps.executeUpdate(); DBTools.close(null, ps, null); } } if (workAddressBook != null) { String workStreet = Property.stringFrom(workAddressBook.getStreet()); String workCity = Property.stringFrom(workAddressBook.getCity()); String workPostalCode = Property.stringFrom(workAddressBook.getPostalCode()); String workState = Property.stringFrom(workAddressBook.getState()); String workCountry = Property.stringFrom(workAddressBook.getCountry()); String workPostalOfficeAddress = Property.stringFrom(workAddressBook.getPostOfficeAddress()); String workExtendedAddress = Property.stringFrom(workAddressBook.getExtendedAddress()); String workLabel = Property.stringFrom(workAddressBook.getLabel()); if (workLabel != null) { String[] label = { workLabel, FIELD_BUSINESS_LABEL }; labels.add(label); } String[] workAddressFields = { workStreet, workCity, workPostalCode, workCountry, workState, workPostalOfficeAddress, workExtendedAddress }; if (!hasOnlyEmptyOrNullContent(workAddressFields)) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_ADDRESS); ps.setLong(1, id); ps.setInt(2, ADDRESS_TYPE_WORK); ps.setString(3, replaceNewLine(StringUtils.left(workStreet, SQL_STREET_DIM))); ps.setString(4, StringUtils.left(workCity, SQL_CITY_DIM)); ps.setString(5, StringUtils.left(workState, SQL_STATE_DIM)); ps.setString(6, StringUtils.left(workPostalCode, SQL_POSTALCODE_DIM)); ps.setString(7, StringUtils.left(workCountry, SQL_COUNTRY_DIM)); ps.setString(8, StringUtils.left(workPostalOfficeAddress, SQL_POSTALOFFICEADDRESS_DIM)); ps.setString(9, StringUtils.left(workExtendedAddress, SQL_EXTENDEDADDRESS_DIM)); ps.executeUpdate(); DBTools.close(null, ps, null); } } // // labels // if (!labels.isEmpty()) { ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_PIM_CONTACT_ITEM); for (int i = 0, l = labels.size(); i < l; i++) { String[] label = labels.get(i); String labelType = label[1]; if ((FIELD_HOME_LABEL).equals(labelType)) { type = TYPE_HOME_LABEL; } else if ((FIELD_BUSINESS_LABEL).equals(labelType)) { type = TYPE_BUSINESS_LABEL; } else if ((FIELD_OTHER_LABEL).equals(labelType)) { type = TYPE_OTHER_LABEL; } else { // // Unknown property: saves nothing // continue; } String labelValue = label[0]; if (labelValue != null && labelValue.length() != 0) { if (labelValue.length() > SQL_LABEL_DIM) { labelValue = labelValue.substring(0, SQL_LABEL_DIM); } ps.setLong(1, id); ps.setInt(2, type); ps.setString(3, labelValue); ps.executeUpdate(); } } DBTools.close(null, ps, null); } if (hasPhoto) { insertPhoto(con, Long.parseLong(cw.getId()), photo); } } catch (Exception e) { throw new DAOException("Error adding contact.", e); } finally { DBTools.close(con, ps, null); } if (log.isTraceEnabled()) { log.trace("Added item with ID '" + id + "'"); } }