I will appreciate if someone answers/clarifies my following questions.
I am using Tomcat Connection pooling.
1. If I understand correctly- with Connection Pooling - Server will take care of opening the connections with DB
So if the Max users allowed is 10, it means that at any given time 10 Concurrent users will be allowed access to DB.
2. Where do I place the code for doing the context lookup?
I have many servlets called by JSP pages and these servlets will be accessing Database.
2 (a) Shall I place the context lookup code in each of the servlets Init Method, but by doing so I am writing the same code again and again.
If I understand correctly the Context lookup code is following 3 lines or Can I squeeze more code in Init()
Context i = new InitialContext();
Context e = (Context) i.lookup("java:comp/env");
DataSource d = (DataSource) e.lookup("jdbc/mytestdb");
Again if I have 30 Servlets, is this still a good idea?
2(b) If there is an alternative to 2 (a), like having another class or something, please elaborate on that
and which part of code should be in this alternative.
My application will be using JSP pages to call servlets that access Database to update or display results.
Thank you very much.
I am using Tomcat Connection pooling.
1. If I understand correctly- with Connection Pooling - Server will take care of opening the connections with DB
So if the Max users allowed is 10, it means that at any given time 10 Concurrent users will be allowed access to DB.
2. Where do I place the code for doing the context lookup?
I have many servlets called by JSP pages and these servlets will be accessing Database.
2 (a) Shall I place the context lookup code in each of the servlets Init Method, but by doing so I am writing the same code again and again.
If I understand correctly the Context lookup code is following 3 lines or Can I squeeze more code in Init()
Context i = new InitialContext();
Context e = (Context) i.lookup("java:comp/env");
DataSource d = (DataSource) e.lookup("jdbc/mytestdb");
Again if I have 30 Servlets, is this still a good idea?
2(b) If there is an alternative to 2 (a), like having another class or something, please elaborate on that
and which part of code should be in this alternative.
My application will be using JSP pages to call servlets that access Database to update or display results.
Thank you very much.