Обсуждение: class loading ...
hello,
i haven't found a way to load dynamically a jdbc3 driver.
for basic driver i use :
Class.forName( "org.postgresql.Driver" ) ;
Connection con = DriverManager.getConnection( url , login , pwd ) ;
...
but with Jdbc3PoolingDateSource it doesn't work. i tried :
Class.forName( "org.postgresql.Driver" ) ;
Jdbc3PoolingDateSource source = new Jdbc3PoolingDateSource() ;
...
or :
Class.forName( "org.postgresql.jdbc3.Jdbc3PoolingDateSource" ) ;
Jdbc3PoolingDateSource source = new Jdbc3PoolingDateSource() ;
...
but it doesn't work. to make it i have to specify :
org.postgresql.jdbc3.Jdbc3PoolingDateSource source =
new org.postgresql.jdbc3.Jdbc3PoolingDateSource() ;
...
but it not dynamically loaded.
thanks, paul.
On Mon, Jan 13, 2003 at 11:53:13AM +0100, paul guermonprez wrote:
> hello,
>
> i haven't found a way to load dynamically a jdbc3 driver.
[...]
> but it doesn't work. to make it i have to specify :
> org.postgresql.jdbc3.Jdbc3PoolingDateSource source =
> new org.postgresql.jdbc3.Jdbc3PoolingDateSource() ;
> ...
>
> but it not dynamically loaded.
If you want to dynamically load a datasource try something like:
Class dsClass = Class.forName("datasource.class.name.here");
javax.sql.DataSource ds = (javax.sql.DataSource)dsClass.newInstance();
then use reflection to configure the datasource (see the JDBC spec for
standardized methods). The same approach works for ConnectionPoolDataSource.
-O