Hi All,
We have hosted an web application and now it is live.
s/w used : Apache, Tomcat 4.1.x, Postgresql 7.x
It seems that there is a major problem with the
database connectivity.
What we are seeing is that over a period of time the
database reports more and more connections from the
our web application until the connection limit (100 on
our setup) is reached.
this is a sample code i am using across application.
whether we need to release the connection explicitly ?
As of now i have not released the connection only i
have closed it .... ?
/*****************************************************/
-------------my db class-----------------
try {
this.setConnection(ConnectionPool.getConnection());
ArrayList arrList = new ArrayList();
con.setAutoCommit(false);
preStmt = con.prepareStatement("SELECT * from t");
resultSet = preStmt.executeQuery();
while (resultSet.next()) {
.....
.....
}
return arrList;
}
catch(Exception ex) {
sberror.append(ex.getMessage());
return null;
}
finally {
try {
con.setAutoCommit(true);
resultSet.close();
preStmt.close();
con.close();
}
catch (SQLException e) {
sberror.append(e.getMessage());
return null;
}
}
-----------my Connectionpool class-----------
public static Connection getConnection() {
Connection con = null;
javax.sql.DataSource ds;
try {
InitialContext ctx = new InitialContext();
ds = (DataSource)
ctx.lookup("java:comp/env/jdbc/postgres");
if (ds != null) {
con = ds.getConnection();
}
else
return null;
}
catch (Exception e) {
return null;
}
return con;
}
/*****************************************************/
please help...
Thanks,
Dinakar
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com