String s = e.getMessage();
String s = e.getMessage().toLowerCase();
    private static Long getNextPkValueForEntityIncreaseBy(String ename, int count, int _increaseBy) {        if (_increaseBy < 1) _increaseBy = 1;        Connection con = ERXJDBCConnectionBroker.connectionBrokerForEntityNamed(ename).getConnection();        try {            con.setAutoCommit(false);            con.setReadOnly(false);        } catch (SQLException e) {            log.error(e, e);        }        String where = "where eoentity_name = '" + ename + "'";        try {            ResultSet resultSet = con.createStatement().executeQuery("select pk_value from pk_table " + where);            con.commit();            boolean hastNext = resultSet.next();            int pk = 1;            if (hastNext) {                pk = resultSet.getInt("pk_value");                pk += _increaseBy;                // now execute the update                con.createStatement().executeUpdate("update pk_table set pk_value = " + pk + " " + where);            } else {                // first time, we need to set i up                con.createStatement().executeUpdate(                        "insert into pk_table (eoentity_name, pk_value) values ('" + ename + "', " + maxIdFromTable(ename) + ")");                pk = maxIdFromTable(ename) + 1;            }            con.commit();            return new Long(pk);        } catch (SQLException e) {            String s = e.getMessage();            if ((s.indexOf("error code 116") != -1) || (s.indexOf("pk_table") != -1 && s.indexOf("does not exist") != -1) ||                     // this is for Oracle                    s.indexOf("ORA-00942: table or view does not exist") != -1) {                try {                    con.rollback();                    log.info("creating pk table");                    con.createStatement().executeUpdate("create table pk_table (eoentity_name varchar(100) not null, pk_value integer)");                    con.createStatement().executeUpdate("alter table pk_table add primary key (eoentity_name)");// NOT                    // DEFERRABLE                    // INITIALLY                    // IMMEDIATE");                    con.commit();                    ResultSet resultSet = con.createStatement().executeQuery("select pk_value from pk_table " + where);                    con.commit();                    boolean hastNext = resultSet.next();                    int pk = 1;                    if (hastNext) {                        pk = resultSet.getInt("pk_value");                        pk++;                        // now execute the update                        con.createStatement().executeUpdate("update pk_table set pk_value = " + pk + " " + where);                    } else {                        // first time, we need to set i up                        con.createStatement().executeUpdate(                                "insert into pk_table (eoentity_name, pk_value) values ('" + ename + "', " + pk + ")");                    }                    con.commit();                    return new Long(pk);                } catch (SQLException ee) {                    ee.printStackTrace();                    throw new RuntimeException("could not create pk table");                } finally {                    ERXJDBCConnectionBroker.connectionBrokerForEntityNamed(ename).freeConnection(con);                }            }            if (count < 10) {                log.error("could not get primkey, trying again " + count + ", error was " + e.getMessage());                return getNextPkValueForEntity(ename);            }            log.error(e, e);            throw new RuntimeException("could not get primkey, original message was " + e.getMessage());        } finally {            ERXJDBCConnectionBroker.connectionBrokerForEntityNamed(ename).freeConnection(con);        }    }