From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Raghavendra MB <mb.ragu@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Class Cast Exception for DataSource
Date: Thu, 22 Feb 2007 10:58:03 +0000
Message-ID: <45DD773B.2070604@enterprisedb.com> (raw)
In-Reply-To: <aa36b6870702212220j7ecae30alb114e71f54e2aca3@mail.gmail.com>
References: <aa36b6870702212220j7ecae30alb114e71f54e2aca3@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: heikki@enterprisedb.com, mb.ragu@gmail.com
Subject: Re: Class Cast Exception for DataSource
In-Reply-To: <45DD773B.2070604@enterprisedb.com>
References: <aa36b6870702212220j7ecae30alb114e71f54e2aca3@mail.gmail.com> <45DD773B.2070604@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox