wood burning stoves 2.0*
The moose likes Other Application Frameworks and the fly likes Manage DataSource via Spring issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Manage DataSource via Spring issue" Watch "Manage DataSource via Spring issue" New topic
Author

Manage DataSource via Spring issue

Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 213
Hi all,

I have setup a jdbc datasource in tomcat's context.xml, e.g. the jndi is jdbc/postgres. How can I retrieve the Connection object from this datasource via Spring configuration file? Please help give me example.


Thanks
Benson
Anadi Misra
Ranch Hand

Joined: Jun 03, 2008
Posts: 69
Hi,

If you are using spring 2.5.X add the following to your application context xml



for apring 2.0.X the way is



Anadi Mishra.
Anadi Misra
Ranch Hand

Joined: Jun 03, 2008
Posts: 69
Forgot to add this earlier

The better way to add the context is to put a xml file with your webapps name under conf/Catalina/localhost directory

See this

Tomcat Config Context
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Manage DataSource via Spring issue