• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

connection object into session...

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using JDBC in a web project. Many user can access the site at the same time. I don't know much about connection pooling, I just heard the term. So I thought this new approach:

I will create a connection object for each user at first visit of user and set it into session attribute of that user and whenever this user will perform some kind of database operation, I will get the same connection object from session and use it....

Please tell me, how is this approach...
Any major drawback???

Thanks a lot.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Any major drawback???


Many major drawbacks - right offhand I can think of:
1. If the site is at all busy you will open MANY more connections than you need and may run into a limit imposed by the database.
2. Every user will experience an extra delay as the connection is opened (as opposed to a minium delay with a connection pool).
3. If the database side closes a Connection the session will be unusable.
You should expend you energy in understanding how connection pools work.
Bill
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Tomcat, which is the most likely, then you can look into DBCP.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic