Hi there,
I've started to use poolman with jsp ( and servlet).
I got a question about how people use poolman in JSP.
I'm using poolman like below.
<%@ page language="java" import="com.codestudio.sql.*,javax.sql.*,java.sql.*" %>
<%
DataSource ds = PoolMan.findDataSource(HeartOfSite.jndi_name);
Connection conn = ds.getConnection();
....
%>
But I guess that PoolMan.findDataSource method is called everytime when
this page is viewed. I looked through the source code of PoolMan.java.
There're about 5 steps in the method(findDataSource). so The code above
might be a little overhead.
so I'm thinking to change the code above to below...
<%@ page language="java" import="com.codestudio.sql.*,javax.sql.*,java.sql.*" %>
<%!
try{
DataSource ds = PoolMan.findDataSource(HeartOfSite.jndi_name);
}catch(SQLException sqle){
System.err.println(sqle.getMessage());
}
%>
<%
Connection conn = ds.getConnection();
...
%>
Since the PoolMan.findDataSource method is in <%! ... %>,
the method is called only once when the page is viewed.
after that, the method never be called. so I think this code is better
(faster)than the first code.
Now I got questions about this code.
Are there any drawbacks in the latter code?
Which code are you guys using ? the first one or the latter one ?
Thank you.
Fumitada Hattori.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets