I would like to store db connection information in the application web.xml file and to fetch it in the application. i read somewhere that it’s possible i just don’t know how.
any ideas?
thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1) Depending on your Application server or Container-Managed server, CREATE a Connection Pool.
2) Link your resource pool in your web.xml
e.g. (Tomcat 5.5 and higher).
I have an Example_DS (Datasource) in my connection pool, and here I share it in my web.xml
This matches my resource created on context.xml (found in META-INF folder) on my web application. Still using Tomcat.
Clearly, you can see I’m using MySQL here.
<Resource />allows you to create a connection pool (in Tomcat)In JBoss….
1) Create a Example_DS.xml file where Example is the name of your datasource.
E.g.
Then user the
<resource-ref>that I gave up earlier to map it to your DS in Jboss. Deploy your DS.xml file in /server/default/deploy/ folder and restart JBoss.Once you’re done, then you can call it in Java using Context.