users@glassfish.java.net

Need for direct jdbc connection information in EJB (url,login,password).

From: <glassfish_at_javadesktop.org>
Date: Fri, 18 Jan 2008 06:08:32 PST

Hi,

In an ejb3 project under glassfish, we are using dbunit to perform database synchronisations between different application instances.

When giving to dbunit a jta datasource or a connection obtained via this datasource, glassfish throws an exception because some work is done out container managed transaction. (Yet absolutely no work seems to be done outside my ejb method. There is only one thread involved. So i don't understand why glassfish complains. Any explanation is welcome ...)

So i switched to a weird way : i make a direct jdbc connection. And to avoid duplication of the configuration, i read the domain file (System.getProperty("com.sun.aas.instanceRoot")+"/config/domain.xml"), parse it and get all informations i need. I works perfecly, but i can't help it : I find that ugly

More generally (forgetting dbunit)
[b]Has anybody a better solution to retrieve the url, password and login of the database underlying the injected datasource in an EJB[/b]?

(I have seen that in debug session in eclipse, all information is readable from my connection object : i see the login, password, url, etc. So my first idea was to use reflection on this instance, but i couldn't find a way to get the information displayed in eclipse debug panel. What is the trick they use ?????. It seems they access information beyond reflection accessible methods and field. How to they do)


Thanks a lot for your time

Olivier
[Message sent by forum member 'otexier' (otexier)]

http://forums.java.net/jive/thread.jspa?messageID=254662