Thanks for your attention.
I don�t know what i did wrong but it's working fine now, whithout any
changes. Maybe i needed just some ice on my brain.
Para: Jakarta Commons Users List
<[EMAIL PROTECTED]>
Rodney Waldhoff cc:
<rwaldhoff@apache. Assunto: Re: How to Pooling
preparedStatements
org>
31/12/2002 07:44
PST
Responder a
"Jakarta Commons
Users List"
I don't see any problems with the sample code you provided. Based upon
the "connection is closed" message, I'm guessing the problem lies in the
way you're interacting with the JDBC classes. Just to rule out the
obvious, you're not trying to use a PreparedStatement after the Connection
has been closed, are you?
Another possiblity is that you've somehow returned a connection to the
pool more than once, and now two clients are holding onto it (and one
closes it out from under the other). I think there are programatic checks
that prevent that in the recent DBCP builds, but I'm not sure off hand how
recently that was added (i.e., it may have been after the 1.0 release).
On Fri, 27 Dec 2002 [EMAIL PROTECTED] wrote:
> Hi,
>
> I am using the dbcp package to pool my connections in our intranet.
> It works very, very well with regular statements but i can't do it work
> with preparedStatements.
> Below is the method that i use. When i try to get a prepStatement i
receive
> this:
>
> "Connection is closed".
>
> Where is the mistake?
>
> Thanks,
>
> S�rgio Bonif�cio.
>
> public DataSource setupDataSource(DBAlias alias)throws Exception {
>
> GenericObjectPool connectionPool = new GenericObjectPool(null);
> connectionPool.setMaxActive(alias.getMaxConexoesSimultaneas());
> connectionPool.setMaxIdle(alias.getMaxConexoesOciosas());
>
> //classe para possibilitar o uso de preparedStatements pelo pool
> StackKeyedObjectPoolFactory stmPoolFactory = new
> StackKeyedObjectPoolFactory();
>
> ConnectionFactory connectionFactory =
> new DriverManagerConnectionFactory(
> alias.getURIConexao(),
> alias.getUser(),
> alias.getSenha());
>
> PoolableConnectionFactory poolableConnectionFactory =
> new PoolableConnectionFactory(
> connectionFactory,
> connectionPool,
> stmPoolFactory,
> null,
> false,
> true);
>
>
> //obtem o data source do objectPool
> PoolingDataSource dataSource = new
> PoolingDataSource(connectionPool);
>
> System.out.println("Pool "+alias.getNomeAlias()+" configurado:");
> System.out.println("maximo de conexoes ativas: "+
> alias.getMaxConexoesSimultaneas());
> System.out.println("maximo de conexoes ociosas: "
> +alias.getMaxConexoesOciosas());
>
> return dataSource;
>
> }
>
>
>
> --
> 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]>