J
josh
Hi, I wrote an application that interact with a database and first
every page like
isert_db.jsp
delete_db.jsp
had the following code:
Class.forName((String)session.getAttribute("driver_name"));
conn =
DriverManager.getConnection((String)session.getAttribute("db_url"),
(String)session.getAttribute("username"),
(String)session.getAttribute("pwd"))
so every time I reloaded the driver and so on...
so I learned some concepts to configure Tomcat to use connection
pooling to improve my db application
and now every page has the following code:
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/articoli");
conn = ds.getConnection();
but the mystery for me is that the first time I load the page I have a
net speed measurement of 200 to 400 ms
and then a speed of 10 to 20 ms. But the same I have with no
connection pooling! How is possible?
May be a JNDI lookup is the problem?
How can I set only once the lookup in JNDI and have for every page a
DataSource object?
every page like
isert_db.jsp
delete_db.jsp
had the following code:
Class.forName((String)session.getAttribute("driver_name"));
conn =
DriverManager.getConnection((String)session.getAttribute("db_url"),
(String)session.getAttribute("username"),
(String)session.getAttribute("pwd"))
so every time I reloaded the driver and so on...
so I learned some concepts to configure Tomcat to use connection
pooling to improve my db application
and now every page has the following code:
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/articoli");
conn = ds.getConnection();
but the mystery for me is that the first time I load the page I have a
net speed measurement of 200 to 400 ms
and then a speed of 10 to 20 ms. But the same I have with no
connection pooling! How is possible?
May be a JNDI lookup is the problem?
How can I set only once the lookup in JNDI and have for every page a
DataSource object?