Of course, below is an example:

public static synchronized Long getNextSeqId(GenericDelegator delegator,
                        String tableName) throws Exception {
                Long sequenceId = null;

                String helperName = delegator.getGroupHelperName("com.aicent");

                Connection conn = ConnectionFactory.getConnection(helperName);

                Statement statement = conn.createStatement();
                statement.execute("SELECT max(id) FROM " + tableName);
                ResultSet results = statement.getResultSet();

                if (results.next()) {

                        sequenceId = new Long(results.getLong(1) + 1);
                }
                Debug.logInfo("MAX ID :" + sequenceId, module);
                return sequenceId;
}

-----Original Message-----
From: Larry.Liu [mailto:xiangqian....@wizitsoft.com] 
Sent: 2009年3月25日 14:51
To: user@ofbiz.apache.org
Subject: how to run a sql directly in java class in ofbiz?

Hi All,

Is there any back door for us to run a SQL and get the result as a resultset
directly in java code in ofbiz?

Thanks.

Regards,
Liu Xiangqian

Wizitsoft Information Technology Ltd.
www.wizitsoft.com | (86) 010-62670653 ext 614

Reply via email to