On Wed, Nov 10, 2010 at 3:02 AM, Pid <[email protected]> wrote:
> On 04/11/2010 12:04, sasidhar prabhakar wrote:
> > dataSource = ConnectionUtil.getDataSource();
> > }
>
> Is the class you posted the only DAO? Could the leak be from another
> class?
>
Some other DAOs are there. Which takes more than removeAbandonedTimeout.
Except timeout I didn't find any unclosed connections, statements and
results.
>
> Can you post ConnectionUtil.java?
>
>
This is DAO class
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ConnectionUtil {
private static Log log = LogFactory.getLog(ConnectionUtil.class);
private static String dataSourceJNDIName = "java:comp/env/jdbc/ds";
private static DataSource dataSource;
public static DataSource getDataSource() {
if(dataSource == null) {
try {
log.info("In the ConnectionUtil:getDataSource():Befor calling lookup on
context");
Context ctx = new InitialContext();
dataSource = (DataSource)ctx.lookup(dataSourceJNDIName);
ctx.close();
} catch(Exception e) {
log.error("Can not create DataSource "+e.getMessage());
throw new IllegalStateException(e.getMessage());
}
}
return dataSource;
}
public static void setDataSource(DataSource ds) {
dataSource = ds;
}
public static Connection getConnection() throws SQLException {
return getDataSource().getConnection();
}
public static void beginTransaction(Connection conn) throws SQLException {
conn.setAutoCommit(false);
}
public static void endTransaction(Connection conn) throws SQLException {
conn.setAutoCommit(true);
}
public static void commit(Connection conn) throws SQLException {
conn.commit();
}
public static void rollback(Connection conn) throws SQLException {
conn.rollback();
}
public static void close(Connection conn) {
if (conn != null) {
try {
if( !conn.isClosed() )
conn.close();
} catch(SQLException e) {
log.error("SQL Exception caught while closing Connection :"+
e.getMessage());
}
}
}
public static void close(Statement stm) {
if (stm != null) {
try {
stm.close();
} catch(SQLException e) {
log.error("SQL Exception caught while closing Statement :"+ e.getMessage());
}
}
}
public static void close(ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch(SQLException e) {
log.error("SQL Exception caught while closing ResultSet :"+ e.getMessage());
}
}
}
}
>
> p
>
>