From: | Heikki Linnakangas <heikki(at)enterprisedb(dot)com> |
---|---|
To: | Raghavendra MB <mb(dot)ragu(at)gmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Class Cast Exception for DataSource |
Date: | 2007-02-22 10:58:03 |
Message-ID: | 45DD773B.2070604@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Raghavendra MB wrote:
> *String postgresDataSource = **"org.postgresql.Driver"**;*
>
> **
>
> *Class dataSourceClass = Class.forName(postgresDataSource);*
>
> *dataSource = (DataSource) dataSourceClass.newInstance();*
>
> **
>
> *I am getting *ClassCast exception when i try to run the code in my java
> application.
>
> Please resolve this problem.
org.postgresql.Driver doesn't implement the javax.sql.DataSource interface.
If you want a DataSource, just use "new
org.postgresql.ds.PGSimpleDataSource()" or "new
org.postgresql.ds.PGPoolingDataSource()" if you want pooling.
If you don't want to use a DataSource, you should be doing:
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql:....");
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2007-02-22 13:06:34 | Re: JDBC object factory |
Previous Message | Oliver Jowett | 2007-02-22 08:54:01 | Re: invalid byte sequence for encoding "UTF8": 0x00 |