Wraps a ResultSet in an Iterator. This is useful when you want to present a non-database application layer with domain neutral data.
ResultSet
Iterator
This implementation requires the ResultSet.isLast() method to be implemented.
ResultSet.isLast()
216217218219220221222223224225226227228229230
if(!Database.tableExists(Constants.Nodes.DatabaseTable.toString())) { String SQL = Common.resourceToString("SQL/Core/Create-Table-" + Database.getType().toString().toLowerCase() + ".sql"); SQL = String.format(SQL, Constants.Nodes.DatabaseTable.getValue()); try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try{ run.update(c, SQL); } catch (SQLException ex) { System.out.println("[iConomy] Error creating database: " + ex); } finally { DbUtils.close(c); }
350351352353354355356357358359360361362363364
} catch (SQLException ex) { System.out.println(ex); return; } QueryRunner run = new QueryRunner(); try { try{ run.query(old, "SELECT * FROM " + table, new ResultSetHandler(){ public Object handle(ResultSet rs) throws SQLException { Account current = null; Boolean next = rs.next(); if(next)
228229230231232233234235236237238239240241242243
return true; } try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try{ String t = Constants.Nodes.DatabaseTable.toString(); Integer amount = run.update(c, "INSERT INTO " + t + "(username, balance, status) values (?, ?, ?)", name.toLowerCase(), balance, status); if(amount > 0) created = true; } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex);
264265266267268269270271272273274275276277278279
return false; } try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try{ String t = Constants.Nodes.DatabaseTable.toString(); Integer amount = run.update(c, "DELETE FROM " + t + " WHERE username=?", name.toLowerCase()); if(amount > 0) removed = true; } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex);
301302303304305306307308309310311312313314315316
return database.hasIndex(name); } try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try { String t = Constants.Nodes.DatabaseTable.toString(); exists = run.query(c, "SELECT id FROM " + t + " WHERE username=?", returnBoolean, name.toLowerCase()); } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex); } finally { DbUtils.close(c); }
341342343344345346347348349350351352353354355356
return balance; } try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try{ String t = Constants.Nodes.DatabaseTable.toString(); balance = run.query(c, "SELECT balance FROM " + t + " WHERE username=?", returnBalance, name.toLowerCase()); } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex); } finally { DbUtils.close(c); }
430431432433434435436437438439440441442443444445
return; } try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try{ String t = Constants.Nodes.DatabaseTable.toString(); int update = run.update(c, "UPDATE " + t + " SET balance=? WHERE username=?", balance, name.toLowerCase()); } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex); } finally { DbUtils.close(c); }
510511512513514515516517518519520521522523524
if(!useInventoryDB() && !useMiniDB() && !useOrbDB()) Thrun.init(new Runnable() { public void run() { try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try{ run.batch(c, query, parameters); } catch (SQLException ex) { System.out.println("[iConomy] Error with batching: " + ex); } finally { DbUtils.close(c); }
551552553554555556557558559560561562563564565566
} Thrun.init(new Runnable() { public void run() { try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try { String t = Constants.Nodes.DatabaseTable.toString(); Integer amount = run.update(c, "DELETE FROM " + t + " WHERE balance=?", Constants.Nodes.Balance.getDouble()); } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex); } finally { DbUtils.close(c); }
591592593594595596597598599600601602603604605606
} Thrun.init(new Runnable() { public void run() { try { QueryRunner run = new QueryRunner(); Connection c = iConomy.Database.getConnection(); try { String t = Constants.Nodes.DatabaseTable.toString(); Integer amount = run.update(c, "TRUNCATE TABLE " + t); } catch (SQLException ex) { System.out.println("[iConomy] Error issueing SQL query: " + ex); } finally { DbUtils.close(c); }