Hello group! I am developing a system using JSP, Java Beans and a MySQL database. The Bean talks to the database, and I was wondering what the best way is to set up the connections to the db? I was also wondering if anyone knows what happens when two people access the same jsp page at the same time - do they get to separate instances of the bean?? Will this cause any problems for my bean in regards to having two requests using the same connection simultaneously? Thanks a lot! /Tomas
Author and all-around good cowpoke
Joined: Mar 22, 2000
The best way to set up connections is with a connection pool. The number of users sharing a JavaBean depends on the scope you assign the bean in the useBean tag. The choices are page, request, session and application. Bill
I agree. Use a connection pool, which should be handled transparently, so you don't have to do much. Also, each user should get a separate bean as long as the scope isn't application.
Joined: Sep 09, 2001
What will be the problems if i don't use connection pool.. pls tell me the points.. Pranit..
Joined: Jan 14, 2002
Thank you all for your answers! >What will be the problems if i don't use connection pool.. pls tell me the points.. You have to be careful so you don't have two users using the same connection simultaneously (that was my main concern, and this could happen if you do it the wrong way). But the biggest pro with connection pooling is efficiency as you don't have to create a new connection for every request - you simply reuse them from the pool. Hope this is correct, Tomas
Joined: Nov 26, 2001
Hi, any body can sujest good resource, where can i find good and nice explanation about implimentation of Connection Pooling using JSP. I am using Professional JSP from WROX publications regards sripad
Joined: Jan 08, 2002
Sripad, I can suggest a very good book called Core Servlets and Java Server Pages by Marty Hall. Their is a website for the book at Core JSP and their is also source code from the chapter on database connection pooling at Jsp/servlet code. I hope this helps and best of luck.