Hi all,

here are three classes I am using for WSAS connection
pooling. I am also sending one mthod of my application
class SearchHelper.

The problem i am facing is if i close the connection
in my DBUtilies class ,
then the statments which to call
ConnectionHelper.release() is not even getting
executed.

whereas if i do not close the connetion in my
DBUtilies class then release method of
ConenctionHelper is called but i am getting an error

Outstanding work on this connection which was not
comitted or rollback by the user has been rolled back.

Kindly let me know where am i doing some mistakes.
This is driving me crazy guys..

would appreciate your immediate repsonses.




/** this is the utility class for obtaining conn from
connectionhelper**/

public class DBUtilities {
public Connection acquire() throws Exception {
if(conConnection == null) {
        conConnection =
ConnectionHelper.getInstance().acquire();
        System.out.println("connection
acquired:@"+conConnection.toString());
        }
        conConnection.setAutoCommit(false);
        return conConnection;
}

public int closeConnection() {
System.out.println("connection in dbiutilities:");
System.out.println(conConnection == null ? "null":
conConnection.toString());
try {
if(conConnection != null) {
System.out.println("conenction in dbutilties
:"+conConnection.isClosed());
ConnectionHelper.getInstance().release(conConnection);
conConnection = null;
}
return 1;
} catch(Exception e) {
return 0;
}
}

public ResultSet doSelect(String sql)  throws
SQLException, Exception {
        ResultSet rsSelect = null;
        Statement stStatement =
acquire().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
        rsSelect = stStatement.executeQuery(sql);
        return rsSelect;
}
}


/** This is the class to obtain the wsas connection
pooling **/

public class ConnectionHelper {
  public Connection acquire() throws
ConnectionException {
        try{
           return
getDataSource().getConnection(getUserID(),getPassword());
        }catch(Exception e){
                  throw new ConnectionException(2, new Object[]
{e.getMessage()});
         }
  }

 public void release(Connection conn) throws
ConnectionException  {
 try {
 System.out.println("connection to be closed in
connection helper:"+conn.toString());
 conn.close();
 System.out.println("connection is closed in
connection helper:"+conn.isClosed());
} catch (Exception e) {
System.out.println("could not close connection in
connection helper class");
} finally {
          conn = null;
          }
  }
}



/** this is the application class that uses the
utility class **/

public class SearchHelper {
public static ArrayList distinctGroupRateTypeNameP()
throws AutoRatesException {
        StringBuffer sql = new StringBuffer("");
        String select = "";
        String tableName = "p_rate_group";
        DBUtilities DBUtil = null;
        if(GROUP_RATE_TYPE_P == null ||
GROUP_RATE_TYPE_P.size() == 0){
        try {
          DBUtil = new DBUtilities();
          GROUP_RATE_TYPE_P = new ArrayList();
          sql.append("select distinct group_name  from
" + tableName + " order by group_name");
        ResultSet rs =
DBUtil.doSelect(sql.toString());
        while (rs != null && rs.next()) {

GROUP_RATE_TYPE_P.add(htmlEncode(rs.getString(1)));
         }
          if(rs != null){
           rs.close();
          }
} catch (Exception exception) {
      //System.err.println("Problem getting distinct
"+select +"  from " + tableName) ;
      throw new AutoRatesException(E00026 ,
exception);
}
finally {
         try  {
              DBUtil.closeConnection();
              } catch (Exception exception) {
  throw new AutoRatesException(E00040 , exception);
}
}
}
return GROUP_RATE_TYPE_P;
        }
}



________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
       visit http://in.tv.yahoo.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to