Обсуждение: A JDBC driver problem

Поиск
Список
Период
Сортировка

A JDBC driver problem

От
"Ahmed Huwait"
Дата:
I'm developing a java program using jdbc, this program is supposed to be able to connect to any kind of database using its url, username, and password. What I did already, is to make it connect to oracle databse using the url: jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb and for driver registration I used:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
 
What I'm asking about is, how to get the suitable driver for a certain database using its url, & how can I register it so I can connect to the database?
 
I used this line:
 
Driver d = DriverManager.getDrivers("jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb");
 
it returns a driver, which appears -when u print it- as:      oracle.jdbc.driver.OracleDriver@20dcd9
while the line:
System.out.println(new oracle.jdbc.driver.OracleDriver());
prints:        oracle.jdbc.driver.OracleDriver@5f5897
 
but when I try to register the Driver d, the connection failed, cause of no suitable driver...
 
can you help me with that?
 

Ahmed Huwait
Computer Science Department,
Purdue University,
West Lafayette, IN, USA.

Re: A JDBC driver problem

От
Jason Stewart
Дата:
It looks like you are using the Oracle driver. You should be using the
Postgresql Driver :). I could probably help you with loading the Postgres
driver.

Jason

At 08:08 PM 8/30/2002 -0500, Ahmed Huwait wrote:
>I'm developing a java program using jdbc, this program is supposed to be
>able to connect to any kind of database using its url, username, and
>password. What I did already, is to make it connect to oracle databse
>using the url:
><mailto:jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb>jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb
>and for driver registration I used:
>DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
>
>What I'm asking about is, how to get the suitable driver for a certain
>database using its url, & how can I register it so I can connect to the
>database?
>
>I used this line:
>
>Driver d =

>DriverManager.getDrivers("<mailto:jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb>jdbc:oracle:thin:@oracle.cs.purdue.edu:1521:orb");

>
>
>it returns a driver, which appears -when u print it-
>as:      oracle.jdbc.driver.OracleDriver@20dcd9
>while the line:
>System.out.println(new oracle.jdbc.driver.OracleDriver());
>prints:        oracle.jdbc.driver.OracleDriver@5f5897
>
>but when I try to register the Driver d, the connection failed, cause of
>no suitable driver...
>
>can you help me with that?
>
>
>----------
>Ahmed Huwait
>Computer Science Department,
>Purdue University,
>West Lafayette, IN, USA.

Jason Stewart
Systems Administrator/Programmer
Right to Life of Michigan
Tel: (616)532-2300
Fax: (616)532-3461