0 Replies Latest reply on Oct 1, 2008 7:54 AM by rajikannan

    Getting Error:closing a connection for you. Please help

    rajikannan

      Hello,
      I'm using jboss3.2.6. I used ejb2.1 (session bean and entity bean[BMP]). I did few data base transations in cmp and few in simple data source connection.

      I'm getting below errors occasionally
      'No managed connection exception
      java.lang.OutOfMemoryError: Java heap space
      [CachedConnectionManager] Closing a connection for you. Plea
      se close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@11ed0d
      5

      I've given below my dao connection code here,

      package com.drtrack.util;
      
      import java.sql.Connection;
      import java.sql.SQLException;
      
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.sql.DataSource;
      
      public class DAOUtil {
      
       private static DataSource _ds;
      
       public Connection con;
       public DAOUtil() throws SQLException {
      
       try {
      
       if (_ds == null)
       assemble();
       if(_ds != null && con == null) {
      
       con = _ds.getConnection();
      
       }
       }catch(SQLException ex) {
      
       ex.printStackTrace();
      
       }
      
       }
      
       private void assemble() {
       Context ic = null;
       try {
      
       ic = new InitialContext();
       DrTrackUtil drutil = new DrTrackUtil();
       _ds = (DataSource) ic.lookup("java:/" + drutil.getText("SOURCE_DIR"));
       drutil = null;
       }catch (Exception e) {
      
       e.printStackTrace();
      
       }finally {
       try {
       ic.close();
       }catch(NamingException ne) {}
       }
      
       }
      
       public void closeConnection() throws SQLException {
      
       if(con != null)
       con.close();
      
       con = null;
       }
      
      }
      


      below is the code with get connection and doing transaction in it.
       public static AccountMasterValueBean getAccountMasterByAcctId(String acctId) {
      
       AccountMasterValueBean bean = null;
       DAOUtil dao = null;
       CallableStatement cst = null;
       ResultSet rs = null;
       try {
       dao = new DAOUtil();
      
       cst = dao.con.prepareCall(DrTrackConstants.MSSQL_USP_ACCOUNTMASTER_BY_ACCTID);
       cst.setObject(1, acctId);
      
       rs = cst.executeQuery();
       if(rs != null && rs.next()) {
      
       bean = new AccountMasterValueBean(
       Integer.valueOf(rs.getString("accountkeyid")),
       rs.getString("latitude"),
       rs.getString("longitude"));
      
       }
       }catch(SQLException se) {
       logger.info("SQL Error: " + se);
       }
       finally {
       if(rs != null){
       try {
       rs.close();
       }catch(SQLException se) {
       logger.info("SQL Error: " + se);
       }
       finally {
       rs = null;
       }
       }
       if(cst != null) {
       try{
       cst.close();
       }catch(SQLException se) {
       logger.info("SQL Error: " + se);
       }
       finally {
       cst = null;
       }
       }
       if(dao != null) {
       try {
       dao.closeConnection();
       }catch(SQLException se) {
       logger.info("SQL Error: " + se);
       }
       finally {
       dao = null;
       }
       }
       }
       return bean;
       }
      


      I closed connections, resultsets and statements properly.
      Why I'm getting these errors.? Where I'm doing wrong. ? Please help me. I have to fix them ASAP.

      Thanks.