how to run a sql directly in java class in ofbiz?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to run a sql directly in java class in ofbiz?

Larry.Liu
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 | Threaded
Open this post in threaded view
|

RE: how to run a sql directly in java class in ofbiz?

Jack Liu-2
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:[hidden email]]
Sent: 2009年3月25日 14:51
To: [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: how to run a sql directly in java class in ofbiz?

Larry.Liu
Thanks :)

Regards,
Liu Xiangqian

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


2009/3/25 Jack Liu <[hidden email]>

> 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:[hidden email]]
> Sent: 2009年3月25日 14:51
> To: [hidden email]
> 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 | Threaded
Open this post in threaded view
|

Re: how to run a sql directly in java class in ofbiz?

BJ Freeman
In reply to this post by Larry.Liu
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

you can look at webtools Entity SQL processor code.

Larry.Liu sent the following on 3/24/2009 11:50 PM:

> 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
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJyhsarP3NbaWWqE4RAhc2AJ9iICVEVMjrAI6sjTx/vKzsgLPIPwCfapF1
CtGjZXYA3XDw9w79PI1UuR4=
=kDjN
-----END PGP SIGNATURE-----