users@glassfish.java.net

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

From: Jagadish Prasath Ramu <Jagadish.Ramu_at_Sun.COM>
Date: Fri, 18 Jan 2008 21:06:18 +0530

On Fri, 2008-01-18 at 06:08 -0800, glassfish_at_javadesktop.org wrote:
> 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 ...)
You can set "non-component-callers" to true in the jdbc connection pool,
such that when the connection is used by a "non-java-ee
component" (dbunit in this case, I guess) it will not be part of
GlassFish's transaction.
>
> 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
You can use AMX to get the connection pool information.
https://glassfish.dev.java.net/javaee5/amx/

Sample code to get monitoring information of connection pool. (Should
help for getting the properties also)
http://blogs.sun.com/JagadishPrasath/entry/monitoring_jdbc_connection_pool_glassfish#3_Using_AMX


Thanks,
-Jagadish
>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>