@Override public int update(AbstractBean ab) { CompanyBean companyBean = (CompanyBean) ab; String query = "update tbl_crm_company set companyName = ?, companyAddress = ?, companyPhone = ?, companyFax = ?, companyEmail = ?, status = ?, writeBy = ?, writeDate = ? where companyId = ?;"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setString(1, companyBean.getCompanyName()); preparedStatement.setString(2, companyBean.getCompanyAddress()); preparedStatement.setString(3, companyBean.getCompanyPhone()); preparedStatement.setString(4, companyBean.getCompanyFax()); preparedStatement.setString(5, companyBean.getCompanyEmail()); preparedStatement.setBoolean(6, companyBean.isStatus()); preparedStatement.setString(7, companyBean.getWriteBy()); preparedStatement.setTimestamp(8, new Timestamp(System.currentTimeMillis())); preparedStatement.setInt(9, companyBean.getCompanyId()); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in update operation in CompanyHelper", e); } operationStatus = dbu.update(preparedStatement); return operationStatus; }
@Override public int add(AbstractBean ab) { CompanyBean companyBean = (CompanyBean) ab; String query = "insert into tbl_crm_company values (?,?,?,?,?,?,?,?,?,?,?);"; try { preparedStatement = DBUtility.connection.prepareStatement(query); preparedStatement.setInt(1, companyBean.getCompanyId()); preparedStatement.setString(2, companyBean.getCompanyName()); preparedStatement.setString(3, companyBean.getCompanyAddress()); preparedStatement.setString(4, companyBean.getCompanyPhone()); preparedStatement.setString(5, companyBean.getCompanyFax()); preparedStatement.setString(6, companyBean.getCompanyEmail()); preparedStatement.setBoolean(7, companyBean.isStatus()); preparedStatement.setString(8, companyBean.getCreateBy()); preparedStatement.setTimestamp(9, new Timestamp(System.currentTimeMillis())); preparedStatement.setString(10, companyBean.getWriteBy()); preparedStatement.setTimestamp(11, new Timestamp(System.currentTimeMillis())); } catch (SQLException e) { ZLog.err("VNC CRM for Zimbra", "Error in insert operation in CompanyHelper", e); } operationStatus = dbu.insert(preparedStatement); return operationStatus; }