Q
quickcur
I think this is a classic java question: Pass by
reference or by value. I have a DatabaseManager class
which takes care of getting conection from connection pool
and releasing the connectoin. I am not sure about the
release part. Here is my code:
class MyMainClass{
public static final void main(String[] args){
Connection connection =
DatabaseManager.getConnection();
....//jdbc work.
DatabaseManager.closeConnection(connection);
....
}
public class DatabaseManager {
public static Connection getConnection(){
Connection connection =
getConectionFromDataSource();
return connection;
}
public static void closeConnection(Connection
conn){
if (conn != null){
try{
conn.close();
}catch(SQLException sqle){
sqle.printStackTrace();
}
}
conn = null;
}}
I am not sure if the connection is released....
Thanks,
reference or by value. I have a DatabaseManager class
which takes care of getting conection from connection pool
and releasing the connectoin. I am not sure about the
release part. Here is my code:
class MyMainClass{
public static final void main(String[] args){
Connection connection =
DatabaseManager.getConnection();
....//jdbc work.
DatabaseManager.closeConnection(connection);
....
}
public class DatabaseManager {
public static Connection getConnection(){
Connection connection =
getConectionFromDataSource();
return connection;
}
public static void closeConnection(Connection
conn){
if (conn != null){
try{
conn.close();
}catch(SQLException sqle){
sqle.printStackTrace();
}
}
conn = null;
}}
I am not sure if the connection is released....
Thanks,