aspose file tools*
The moose likes JBoss/WildFly and the fly likes (Application scoped) DB connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "(Application scoped) DB connection pooling" Watch "(Application scoped) DB connection pooling" New topic
Author

(Application scoped) DB connection pooling

Bojan Tomic
Greenhorn

Joined: Apr 08, 2008
Posts: 25
I am trying to get connection pooling in JBoss 4.2.2, and for that purpose, I've been reading some JBoss docs. Now, one thing confuses me, is it possible to get connection pooling without modifying JBoss' configs (so that it affects all application), but instead configure pooling for a single application only (like you do in Tomcat with context.xml)?
My goal is to be able to give the application to someone without making them reconfigure their server.
Since this is easily doable in Tomcat, I presumed it's doable in JBoss, but I can't seem to find a way to do it.

In case it is needed, here's my META-INF/context.xml from Tomcat deployment


and my resource related poriton of WEB-INF/web.xml


I tried deploying to JBoss without any changes, but got a NamingException as jdbc/mysql was never properly bound.
I am new to JBoss so I might have said some nonsense. In that case, please bear with me and tell me what I have got wrong.

Thanks for the time.
[ October 17, 2008: Message edited by: Veggen Skrikk ]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

I assume you are talking about database connection pooling (and not HTTP connection pooling). If so, this is easy to do. The connection pool is defined in the *-ds.xml file. You can provide this file with your application (you can even embed the *-ds.xml file in your EAR), and you can have all of your applications use the same *-ds.xml-defined data source.

Look at docs/examples/jca for example *-ds.xml files for a variety of databases.


JBoss In Action
Bojan Tomic
Greenhorn

Joined: Apr 08, 2008
Posts: 25
Thank you Peter for this answer. Just one more thing, if it's not a problem; where should I place *-ds.xml (inside EAR) for JBoss to find it? Can I do this with WARs as well?

Thanks again for your time.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

For an EAR, place the *-ds.xml in the base directory. You must then also provide a META-INF/jboss-app.xml file containing:



Unfortunately, this will not work in a WAR file. But you could have an EAR with the *-ds.xml and WAR.
Bojan Tomic
Greenhorn

Joined: Apr 08, 2008
Posts: 25
Ok, thanks a lot for the tip. I'll see what I can do.
Btw. I can't wait for your book to come out. I'm in desperate need of a good JBoss guide.
[ October 17, 2008: Message edited by: Veggen Skrikk ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: (Application scoped) DB connection pooling