I have a Connection instance (that I got from a JDBCPool) in my
JSP. Can I pass this instance to a JavaBean in the constructor of the bean (from my JSP) and have the bean use this connection (instead of creating its own connection instance)? May the below code cause any errors down the road where there are several connections to the database?
Thx.
Example:
--JSP Code--
DBAccess dba = new DBAccess();
Connection con = null;
try {
con = dba.getConnection();
} catch (SQLException sqle) {
}
OrderedThreads ot = new OrderedThreads(con);
--JavaBean Constructor--
public Connection con = null;
public OrderedThreads(Connection cn) {
con = cn;
try {
stmt = con.createStatement();
} catch (SQLException sqle) {
sqle.printStackTrace();
}