· 6 years ago · Jul 03, 2019, 12:52 PM
1public static void main(String[] args) {
2 ...
3
4 final int interval = Constants.INTERVAL;
5 QuickBooksInvoices qbInvoices = new QuickBooksInvoices(filename);
6 qbInvoices.testConnection();
7
8 log.log(Level.INFO, "Checking invoices with an interval of " + interval + " seconds...");
9 while (isRunning == true) {
10 qbInvoices.process();
11 try {
12 Thread.sleep(interval * 1000);
13 } catch (InterruptedException e) {
14 }
15 }
16}
17
18public void process() {
19 errorBuffer.clear(); // These are array lists
20 successBuffer.clear(); // These are array lists
21
22 try (Connection conn = DriverManager.getConnection(dbURI, dbUser, dbPassword)) {
23 ArrayList<com.xxx.quickbooks.model.wdg.Invoice> a = getInvoices(conn);
24
25 OAuthToken token = null;
26 if (a.size() > 0) {
27 // Never gets here - no results
28 }
29
30 for (com.xxx.quickbooks.model.wdg.Invoice invoice : a) {
31 // Never gets here - no results
32 }
33 } catch (Exception e) {
34 writeLog(Level.ERROR, ExceptionUtils.getStackTrace(e));
35 }
36
37 }
38
39private ArrayList<com.xxx.quickbooks.model.wdg.Invoice> getInvoices(Connection conn) {
40 ArrayList<com.xxx.quickbooks.model.wdg.Invoice> invoices = new ArrayList<com.xxx.quickbooks.model.wdg.Invoice>();
41
42 String sql = "select " +
43 "id," +
44 "type," +
45 "status," +
46 "business_partner_id," +
47 "invoice_number," +
48 "total," +
49 "nrc," +
50 "szrc," +
51 "trans_ts," +
52 "warehouse_id," +
53 "due_date," +
54 "ref_number," +
55 "payment_type " +
56 "FROM dv_invoice " +
57 "WHERE exported_ts is NULL AND exported_msg is NULL ; ";
58 try (
59 PreparedStatement stmt = conn.prepareStatement(sql);
60 ResultSet rs = stmt.executeQuery();
61 ) {
62 while (rs.next()) {
63 // Never gets here - no results
64 }
65 } catch (SQLException e) {
66 writeLog(Level.ERROR, ExceptionUtils.getStackTrace(e));
67 }
68 return invoices;
69 }