we have these classes below,
public class DatabasePool {
public Connection getConnection() {
InitialContext context = new InitialContext();
//Look up our data source
ConnectionPoolDataSource ds = (ConnectionPoolDataSource)
//Allocate and use a connection from the pool
Connection con = ds.getConnection();
return con;
}
}
public class Grade {
DatabasePool dbPool = new DatabasePool();
public Vector get Type() {
Vector v = new Vector();
Connection con = null;
Statement st = null;
ResultSet rs = null;
String querySql = "SELECT * FROM QType ORDER BY SEQUENCE";
try
{
con=ConnectionBean.getConn
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next())
{
voQType vo = new voQType();
vo.setPKQType(rs.getInt("P
vo.setQType(rs.getString("
v.add(vo);
}
rs.close();
rs = null;
}
catch(Exception E)
{
System.err.println("Q.java
}
finally
{
stmt.close();
stmt = null;
con.close();
close = null;
}
return v;
}
}
Grade object will create new DatabasePool object and call the getConnection() method. We used the close() method to close the connection at the end of the query. Does it close the connection instance or the physical connection the database? When we call the getConnection() method, does it actually create a new physical connection database or simply getting a new connection instance from the connection pool?
Please help to clarify.
Main Topics
Browse All Topics





by: objectsPosted on 2007-10-03 at 02:45:42ID: 20005022
con.close();