You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Peter Donald <pe...@apache.org> on 2002/02/20 21:29:41 UTC
Re: FW: JdbcConnectionPool
On Thu, 21 Feb 2002 05:33, Mahmoud Parsian wrote:
> Gentelmen, please take a look at the following. Thanks.
> mp
>
> -----Original Message-----
> From: Mahmoud Parsian
> Sent: Tuesday, February 19, 2002 5:23 PM
> To: 'bloritsch@apache.org'
> Subject: JdbcConnectionPool
>
>
> He Berin,
>
> Do you have an example of using JdbcConnectionPool in excalibur
> environment. Even though I have initialized the pool, but still it gives an
> error: Here is what I have:
>
> Many thanks in advance.
> Mahmoud
>
> TestPool.java
> -------------
> ....
> String username = "root";
> String password = "";
> String url = "jdbc:mysql://localhost/octopus";
> String driver = "org.gjt.mm.mysql.Driver";
> String connectionClass =
> "org.apache.avalon.excalibur.datasource.JdbcConnection";
>
> try {
>
> Class.forName(driver);
> System.out.println("*** driver loaded., driver="+driver);
>
> JdbcConnectionFactory factory = new JdbcConnectionFactory(url,
>
> username,
>
> password,
>
> true, //autocommit?
>
> "SELECT 1 from dual", // I have this table
>
> connectionClass);
>
> System.out.println("*** factory created="+factory);
>
> DefaultPoolController controller = new DefaultPoolController( 2 /*
> grow amount */ );
> System.out.println("*** controller created="+controller);
> JdbcConnectionPool dsPool = new JdbcConnectionPool(factory,
>
> controller,
> 5,
> // min
> 20,
> // max
> true);
> // autocommit?
>
>
>
>
> System.out.println("*** dsPool created="+dsPool);
>
> // set time in millis pool will block waiting for a
> //connection to be returned to an empty pool
> dsPool.setTimeout( 1000 );
>
> dsPool.initialize();
> System.out.println("*** dsPool initialized");
> // the dsPool is active now
>
> int size = dsPool.size();
> System.out.println("*** dsPool size="+size);
>
> Poolable poolable = dsPool.get();
> System.out.println("*** poolable="+poolable);
>
> But when I run it, I get the following error:
> error:java.lang.IllegalStateException: You cannot get a Poolable before the
> pool is initialized
> java.lang.IllegalStateException: You cannot get a Poolable before the pool
> is initialized
> at
> org.apache.avalon.excalibur.pool.DefaultPool.get(DefaultPool.java:109)
> at JdbcConnectionPool.get(JdbcConnectionPool.java:152)
> at TestPool.main(TestPool.java:68)
--
Cheers,
Pete
*------------------------------------------------------*
| "Computers are useless. They can only give you |
| answers." - Pablo Picasso |
*------------------------------------------------------*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>