This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

closing connections obtained by JDBC Datasource look up

 
Mohamed Iqzas
Ranch Hand
Posts: 73
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For the first time I have configured my local JBoss 7 AS for JNDI Datasource Look up.

I blindly followed instructions given in jboss forums and it worked well for me.

But if my web application is inactive for a long time and if i try login to my application new datasource lookup is working fine.

for every login my application will make a DS lookup and jdbc connection calls are working fine. But in the next page I am using a servlet that uses one connection instance to serve all the requests. Now it is not making a new DS lookup and the old connection created during servlet instantiation is being used. So now I have to restart my server to instantiate this servlet again. I am making a ds look up call in the init method of my servlet. I thought its a good way of doing but it is causing problems if the servlet is inactive for very long time .. I guess the connection is getting closed. Do I have to create a connection everytime inside service methods instead of doing it in init() method? or I have to change something else?

I am using MY SQL as the DB.

Thanks in advance.
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should guide you database connection in init() of servlet
 
Mohamed Iqzas
Ranch Hand
Posts: 73
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much.

Got a lot of useful info. and Exactly what i wanted :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic