-
1. Re: Need to use SQL in app that is using CMP
milowe Mar 3, 2004 6:41 AM (in response to davout)Get your Connection from the DataSource and fire away your SQL the
usual way.Context initial = new InitialContext(); DataSource ds = (DataSource)initial.lookup("Name-in-ds.xml"); Connection con = ds.getConnection();
-
2. Re: Need to use SQL in app that is using CMP
davout Mar 3, 2004 12:05 PM (in response to davout)In the code example...
DataSource ds = (DataSource)initial.lookup("Name-in-ds.xml");
... do you mean "DefaultDS" for "Name-in-ds.xml"? -
3. Re: Need to use SQL in app that is using CMP
milowe Mar 4, 2004 1:41 AM (in response to davout)Yes, it could be "java:/DefaultDS" or whatever your JNDI for the DS you are using is bound to.
-
4. Re: Need to use SQL in app that is using CMP
amayingenta Mar 4, 2004 5:20 AM (in response to davout)If your dynamic queries aren't too complex you might be able to use dynamic JBoss-QL - it's an extension of EJB-QL which you can use dynamically.
Whilst you can't do everything that you can in SQL, it's useful if you have lots of different queries that could be written in EJB-QL but you can't define them all in advance.
We use it for an interface that dynamically queries the data controlled by our CMP entities.
There's details on how to use it in the JBossCMP for-pay documentation.