• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about shared DB connection

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read from Manning JSP book that I can create a db connection object and set it as an attribute of the application object so this db connection can be shared by all JSPs and All users of this application.
My question is, what is going to happen when there is concurrent access to the db connection, say, multiple users queries/updates the database through this db connection at the same time? If this setup works, then what is the point to implement connection pooling?
Thanks for your words of wisdom.
Arnold
 
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
Obviously concurrent use by multiple requests would be a disaster. You would have to provide for synchronizing on the connection to prevent that, and you would also have to provide for regenerating the connection if it got closed by the database end, etc etc.
You might as well use a connection pool.
Bill
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The advantage of connection pooling is that u have more number of database connections ready for use. Hence it can support many requests at a given instance, which implies scalability.
Its not the same with the shared DBConnection
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general, all these older mechanisms are made nearly obsolete by JSTL's <sql:*> tags. These tags generally use DataSource objects that are managed behind the scenes, thus making the JSP pages simpler and the access both correct and efficient (assuming the DataSource is correct and efficient). Of course, this all assumes you want to access databases from your JSP pages directly.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mr Bayern,

I am used to the old way of using jsp to interact with databases and the problems associated with connections, etc.

I have been experimenting with beans to handle all business logic, generally how does jstl work and is it's benefit only to database access.

Need a jump start on the topic.
Thanks
 
Claude Nicholson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dont worry dude
Found some information on earlier postings. To be honest I have heard of taglibaries but concentrated on beans to do the work.
Does your book cover all i'd need to now to effectively use it. Cause it seems based on some of the postings that the functionality of jstl depends on the server used.
I asked for a jump start before now I need a road.

Thanks again
 
reply
    Bookmark Topic Watch Topic
  • New Topic