Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Manage DataSource via Spring issue

 
Benson Fung
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Misra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic