connection problem - why idle
От | dinakar |
---|---|
Тема | connection problem - why idle |
Дата | |
Msg-id | 20040306053024.25693.qmail@web10706.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: class not found exception (Oliver Jowett <oliver@opencloud.com>) |
Список | pgsql-jdbc |
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
В списке pgsql-jdbc по дате отправления: