protected void init() { try { _con = WebAppConnection.getWebAppConnection().getConnection(); } catch (OptInCustomerException ex) { AppLog.writeAuditLog( "OptIN Driver OptInCustomerException: no connection to dB " + ex.getMessage()); System.out.println( "OptIN Driver OptInCustomerException: no connection to dB " + ex.getMessage()); System.exit(1); } catch (Exception exe) { AppLog.writeAuditLog("OptIN Driver Exception: " + exe.getMessage()); System.out.println("OptIn Driver Exception : " + exe.getMessage()); System.exit(1); } }
protected ArrayList getOptInCustomers() { int counter = 0; ArrayList _rowset = new ArrayList(); // get CAPBatch properties: // _limit = number of letters to print // _sql = the Select query int _limit = Integer.parseInt(_appProp.getProperty(SEGMENTPROPERTY)); String _sql = _appProp.getNoEnvironmentProperty(SQLREADPROPERTY); try { ResultSet _resultSet = null; Statement _stmt = null; _stmt = _con.createStatement(); ResultSet _rs = _stmt.executeQuery(_sql); if (_rs == null) { AppLog.writeAuditLog("LetterDriverDataBean - no customer letters to process."); System.out.println("LetterDriverDataBean - no customer letters to process."); return null; } for (; _rs != null && _rs.next() && counter < _limit; counter++) { try { CustomerValue _customer = new CustomerValue(AppLog); _customer.setCustomerData(_rs); _rowset.add(counter, _customer); _customer = null; } catch (OptInCustomerException e) { System.out.println("Populating CustomerValue object failed " + e.getMessage()); AppLog.writeAuditLog("Populating CustomerValue object failed " + e.getMessage()); } } } catch (SQLException _e) { AppLog.writeAuditLog("SQL Exception: occurred reading DAOptinCustomer " + _e.getMessage()); System.out.println("SQL Exception occurred reading DAOptInCustomer " + _e.getMessage()); } finally { // close the connection try { closeConnection(); } catch (OptInCustomerException _io) { System.out.println("DB close exception occurred. terminate job."); } } System.out.println("There were " + counter + " customers read from DAOptInCustomer table"); return _rowset; }