I'm getting in trouble with JDBC Pool.
After all use of a connection, I close resultSet, I close the statement and
then close Connection.
After all closes I get "returned object", except in one case. If anyone can
analyse this code and give some idea, please do:

    public List getAll() throws RemoteException {
        ArrayList lista = null;
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
        MyObject tipo = null;

        try {
            StringBuffer sql = new StringBuffer( "select co_tipo, ds_tipo
from tipo order by co_tipo" );
            connection = this._getConnection( ); // this method returns one
connection from the pool.

            statement = connection.createStatement( );
            resultSet = statement.executeQuery( sql.toString( ) );
            tipo = null;

            lista = new ArrayList( );

            while( resultSet.next( ) ) {
                try {
                  tipo = new MyObject( );
                  tipo.codigo = resultSet.getInt( 1 );
                  tipo.descricao = resultSet.getString( 2 );
                } catch( Exception e ) {
                  e.printStackTrace( );
                }

                lista.add( tipo );
            }
        } catch( Exception e ) {
            e.printStackTrace();
            lista = null;
        } finally {
            this._close( connection, statement, resultSet ); //this method
closes, in order, ResultSet, Statement and then Connection
        }

        return lista;
    }

    private void _close( Connection connection, Statement statement,
ResultSet resultSet ) {
      if( _DEBUG )
        System.out.println("_close( Connection, Statement, ResultSet )" );

        if( resultSet != null ) {
            try {
                resultSet.close( );
            } catch( Exception e ) {
              e.printStackTrace( );
            }
        }

        if( statement != null ) {
            try {
                statement.close( );
            } catch( Exception e ) {
              e.printStackTrace( );
            }
        }

        if( connection != null ) {
            try {
                connection.close( );
            } catch( Exception e ) {
              e.printStackTrace( );
            }
        }
    }

    private Connection _getConnection( ) {

        DataSource dataSource = null;
        Connection connection = null;

        try {
            javax.naming.Context context = new
javax.naming.InitialContext( );

            try {
                dataSource = ( DataSource )context.lookup(
"java:/jdbc/myDB" );
            } catch( Exception e2 ) {
                e2.printStackTrace();
                throw new EJBException( "Erro buscando o DataSource: " +
e2.toString( ) );
            }

            try {
                connection = dataSource.getConnection( );
            } catch( Exception e2 ) {
                e2.printStackTrace();
                throw new EJBException( "Erro buscando Connection: " +
e2.toString( ) );
            }

        } catch( Exception e1 ) {
            e1.printStackTrace();
            throw new EJBException( "N�o foi poss�vel obter o \"Initial
Context\": " + e1.toString( ) );
        }

        return connection;
    }


I have several other methods that works exactly same way, but they closes
connection when I call _close in finally clause...
Maybe this a JDBC Pool bug? Setting connection time out in JCML
configuration file does not release connection nevermore...

Anyone can give a light?


Thanks,


Edson Richter

----- Original Message -----
From: "David Jencks" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 19, 2001 4:55 PM
Subject: Re: [JBoss-user] JDBC Pool


> On 2001.11.19 14:34:06 -0500 Edson Carlos Ericksson Richter wrote:
> > what means numbers 0, 2 and 10 in
> >
> > [jdbc/myConnection] Pool jdbc/myConnection [0/2/10] returned object
> > org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@7ec028 to the pool.
> >
> > log message?
>
> In the pool, there are 0 free connections, 2 are created (and, noticing
the
> 0, in use), and the max capacity is 10.
> david jencks
> >
> >
> > Thanks,
> >
> >
> > Edson Richter
> >
> >
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> > <HTML><HEAD>
> > <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
> > <META content="MSHTML 6.00.2600.0" name=GENERATOR>
> > <STYLE></STYLE>
> > </HEAD>
> > <BODY bgColor=#ffffff>
> > <DIV><FONT face=Arial size=2>what means numbers 0, 2 and
> > 10&nbsp;in</FONT></DIV>
> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> > <DIV><FONT face=Arial size=2>[jdbc/myConnection] Pool jdbc/myConnection
> > [0/2/10]
> > returned object org.jboss.pool.jdb<A
> >
href="mailto:org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@7ec028";>c.xa.wr
apper.XAConnectionImpl@7ec028</A>
> >
> > to the pool.</FONT></DIV>
> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> > <DIV><FONT face=Arial size=2>log message?</FONT></DIV>
> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> > <DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> > <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
> > <DIV><FONT face=Arial size=2>Edson Richter</FONT></DIV>
> > <DIV>&nbsp;</DIV></BODY></HTML>
> >
> > BEGIN:VCARD
> > VERSION:2.1
> > N:Richter;Edson;Carlos Ericksson
> > FN:Edson Carlos Ericksson Richter
> > NICKNAME:Richter
> > ORG:ECONET Solu��es Web;Sistemas Corporativos
> > TITLE:Gerente de Projetos
> > TEL;WORK;VOICE:61 3265115
> > ADR;WORK:;;Liberty Mall, Torre B, Sala 1011;Bras�lia;DF;70000-000;Brasil
> > LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Liberty Mall, Torre B, Sala
> > 1011=0D=0ABras=EDlia, DF 70000-000=0D=0ABrasil
> > URL;WORK:http://www.carabrasilia.com.br
> > EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
> > EMAIL;INTERNET:[EMAIL PROTECTED]
> > EMAIL;INTERNET:[EMAIL PROTECTED]
> > REV:20011119T193406Z
> > END:VCARD
> >
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to