Sorry forgot the code. If you are not familiar with AspectJ 
http://aspectj.org/servlets/AJSite

AspectJ connection pooling written by Ivan Kiselev consists of 2 aspect
classes

package aspects;

import java.sql.*;
import java.util.*;

public aspect Pooling{

   private static Stack pool = new Stack();

   pointcut poolGet():
        call( static Connection DriverManager.getConnection(..) );
   pointcut poolPut();
        call( void Connection.close() );

   Connection around() throws SQLException: poolGet(){
      synchronized(pool){

           // who is calling this
           System.out.println(
                thisJoinPoint.getTarget() + " | " +
                thisJoinPoint.getThis() + " | " +
                thisJoinPoint.getSignature()+" | " +
                thisJoinPoint.getKind()+ " | " +
                thisJoinPoint.getSourceLocation.getFileName()+ " | " +
                thisJoinPoint.getSourceLocation.getLine() );

           if( pool.empty() )
              return proceed();

           return (Connection)pool.pop();
        }
   }
   
   void around(): poolPut(){
        Connection conn = (Connection)thisJoinPoint.getTarget();
        pool.push(conn);

   }
}

//*************************************

package aspects;

import java.sql.*;
import java.util.*;

public aspect ConnectionChecking dominates Pooling{

   Connection around throws SQLException:
        call( static Connection DriverManager.getConnection(..) ){

        Connection conn;
        
        do{
           conn = proceed();
        }while( bad(conn) );

        return conn;
   }

   private boolean bad( Connection conn ){

        try{
           Statement stmt = conn.createStatement();
           ResultSet rs = stmt.executeQuery("select 2+2")//find a select
that works for you

           if( rs.next() )
                rs.getString(1);
           
           rs.close();
           stmt.close();
        }catch( SQLException sqle ){
           return true;
        }
        return false;
   }
}

-----Original Message-----
From: Jackson, Stephen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 27, 2002 4:59 PM
To: 'Struts Users Mailing List'
Subject: RE: [OT] conn pooling - what next?


You need to use Aspects to handle this problem.

-----Original Message-----
From: Rick Reumann [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 27, 2002 10:40 AM
To: Struts List
Subject: [OT] conn pooling - what next?


I know this topic has come up in the past, but I'm wondering if
someone can help. I haven't tried Struts or Tomcat connection pooling,
but have tried some others recommended. The latest one recommended on
a Tomcat post was http://connpool.jensn.de/index.html and it seemed to
be working great.

The problem, though, with this one and other ones I've tried, is that
when the open connections are manually killed by the DBA the conn pool
does not work.

I end up with an error like this:

      java.sql.SQLException: Io exception:
      Software caused connection abort:
      socket write error

or

      java.sql.SQLException:
      ORA-00028: your session has been killed


Is there connection pooling that someone can recommend that will be
able to handle when connections are manually killed? I wouldn't be
surprised with the way things are set up here that no connection
pooling will work in our environment, but maybe someone can recommend
a very good one to use. Should I go with the struts pooling, tomcat's,
or maybe even poolman if it's still around?

Thanks for any help.

-- 

Rick
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to