if (logSql) { long logTimeStop = System.currentTimeMillis(); logSqlStatement("SQL SELECT_MAX", map.getTableName(), logTimeStart, logTimeStop, q); }
    public synchronized String generateMaxID(DbMapping map)                                      throws Exception {        // Transactor tx = (Transactor) Thread.currentThread ();        // tx.timer.beginEvent ("generateID "+map);        String retval = null;        Statement stmt = null;        try {            Connection con = map.getConnection();            String q = new StringBuffer("SELECT MAX(").append(map.getIDField())                                                      .append(") FROM ")                                                      .append(map.getTableName())                                                      .toString();            stmt = con.createStatement();            ResultSet rs = stmt.executeQuery(q);            // check for empty table            if (!rs.next()) {                long currMax = map.getNewID(0);                retval = Long.toString(currMax);            } else {                long currMax = rs.getLong(1);                currMax = map.getNewID(currMax);                retval = Long.toString(currMax);            }        } finally {            // tx.timer.endEvent ("generateID "+map);            if (stmt != null) {                try {                    stmt.close();                } catch (Exception ignore) {                }            }        }        return retval;    }