Using the JDBC Driver in version 7.02

Started by Justin Jaynesalmost 26 years ago6 messagesgeneral
Jump to latest
#1Justin Jaynes
justinjaynes@hotmail.com

Hello. I am using Postgres 7.02 on my redhat linux box. I have installed
the JDK and a JSP engine.

I have also copied the JDBC level 4 Drivers that came with postgresql 7.02
onto my hard drive.

When I try to interface with it in java, even after loading the driver with
the line:

Class.forName("org.postgresql.Driver");

I get an error that the DriverManager cannot find a suitable driver.

The code I use to connect goes as follows:

Connection chamber = DriverManager.getConnection("localhost:5432");

I also tried it as:

Connection chamber =
DriverManager.getConnection("localhost:5432","username","password");

and still no luck.

Can anyone help with this problem?

I have two suspicions: First, that I am not pointing to the right class in
the jar file. Driver.class might be the wrong file to start with. Second,
maybe my server is not taking requests properly, so Java says "hey, this
driver is not working." when it's not the drivers fault, but the servers
fault.

Just so you know, I set up my server to trust all localhost connections.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

#2Joseph Shraibman
jks@selectacast.net
In reply to: Justin Jaynes (#1)
Re: Using the JDBC Driver in version 7.02

You have to format your url properly so the java runtime can figure out
what driver to use for the connection.

Justin Jaynes wrote:

Show quoted text

Hello. I am using Postgres 7.02 on my redhat linux box. I have installed
the JDK and a JSP engine.

I have also copied the JDBC level 4 Drivers that came with postgresql 7.02
onto my hard drive.

When I try to interface with it in java, even after loading the driver with
the line:

Class.forName("org.postgresql.Driver");

I get an error that the DriverManager cannot find a suitable driver.

The code I use to connect goes as follows:

Connection chamber = DriverManager.getConnection("localhost:5432");

I also tried it as:

Connection chamber =
DriverManager.getConnection("localhost:5432","username","password");

and still no luck.

Can anyone help with this problem?

I have two suspicions: First, that I am not pointing to the right class in
the jar file. Driver.class might be the wrong file to start with. Second,
maybe my server is not taking requests properly, so Java says "hey, this
driver is not working." when it's not the drivers fault, but the servers
fault.

Just so you know, I set up my server to trust all localhost connections.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

#3Peter T Mount
peter@retep.org.uk
In reply to: Justin Jaynes (#1)
Re: Using the JDBC Driver in version 7.02

----- Original Message -----
From: Joseph Shraibman <jks@selectacast.net>
To: Justin Jaynes <justinjaynes@hotmail.com>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, July 10, 2000 9:57 PM
Subject: Re: [GENERAL] Using the JDBC Driver in version 7.02

You have to format your url properly so the java runtime can figure out
what driver to use for the connection.

Justin Jaynes wrote:

Hello. I am using Postgres 7.02 on my redhat linux box. I have

installed

the JDK and a JSP engine.

I have also copied the JDBC level 4 Drivers that came with postgresql

7.02

onto my hard drive.

When I try to interface with it in java, even after loading the driver

with

the line:

Class.forName("org.postgresql.Driver");

I get an error that the DriverManager cannot find a suitable driver.

The code I use to connect goes as follows:

Connection chamber = DriverManager.getConnection("localhost:5432");

This isn't a valid JDBC URL. You'll need something like:

jdbc:postgresql:database <= Use when on local host
jdbc:postgresql://server/database <= Use when on remote host

I also tried it as:

Connection chamber =
DriverManager.getConnection("localhost:5432","username","password");

and still no luck.

Can anyone help with this problem?

I have two suspicions: First, that I am not pointing to the right class

in

the jar file. Driver.class might be the wrong file to start with.

Second,

That is the correct one (other than when using data sources)

Show quoted text

maybe my server is not taking requests properly, so Java says "hey, this
driver is not working." when it's not the drivers fault, but the servers
fault.

Just so you know, I set up my server to trust all localhost connections.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

#4Marko Kreen
markokr@gmail.com
In reply to: Peter T Mount (#3)
Re: Using the JDBC Driver in version 7.02

On Tue, Jul 11, 2000 at 12:05:29AM +0100, Peter Mount wrote:

----- Original Message -----
From: Joseph Shraibman <jks@selectacast.net>
To: Justin Jaynes <justinjaynes@hotmail.com>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, July 10, 2000 9:57 PM
Subject: Re: [GENERAL] Using the JDBC Driver in version 7.02

Justin Jaynes wrote:

the line:

Class.forName("org.postgresql.Driver");

Try:

Class.forName("postgresql.Driver");

Ofcource, check that postgresql.jar is in classpath. If Java >= 1.2,
you can instead drop it in $JAVA_HOME/jre/lib/ext.

I get an error that the DriverManager cannot find a suitable driver.

The code I use to connect goes as follows:

Connection chamber = DriverManager.getConnection("localhost:5432");

This isn't a valid JDBC URL. You'll need something like:

jdbc:postgresql:database <= Use when on local host
jdbc:postgresql://server/database <= Use when on remote host

--
marko

#5Nagel, Thomas
tna@FIZ-Karlsruhe.DE
In reply to: Marko Kreen (#4)
AW: Using the JDBC Driver in version 7.02

Justin Jaynes wrote:

the line:

Class.forName("org.postgresql.Driver");

Try:

Class.forName("postgresql.Driver");

In 7.02 the above is WRONG,

Class.forName("org.postgresql.Driver");

is right ...

(Drivername has changed in this version)

Show quoted text

Ofcource, check that postgresql.jar is in classpath. If Java >= 1.2,
you can instead drop it in $JAVA_HOME/jre/lib/ext.

I get an error that the DriverManager cannot find a

suitable driver.

The code I use to connect goes as follows:

Connection chamber =

DriverManager.getConnection("localhost:5432");

This isn't a valid JDBC URL. You'll need something like:

jdbc:postgresql:database <= Use when on local host
jdbc:postgresql://server/database <= Use when on remote host

--
marko

#6Peter T Mount
peter@retep.org.uk
In reply to: Justin Jaynes (#1)
Re: Using the JDBC Driver in version 7.02

See below
--
Peter T Mount peter@retep.org.uk, peter@retepdigital.com, me@petermount.com
Homepage: http://www.retep.org.uk Contact details @ http://petermount.com
PostgreSQL JDBC: http://www.retep.org.uk/postgres/
Java PDF generator: http://www.retep.org.uk/pdf/

----- Original Message -----
From: Marko Kreen <marko@l-t.ee>
To: Peter Mount <peter@retep.org.uk>
Cc: Joseph Shraibman <jks@selectacast.net>; Justin Jaynes
<justinjaynes@hotmail.com>; <pgsql-general@postgresql.org>
Sent: Tuesday, July 11, 2000 12:58 PM
Subject: Re: [GENERAL] Using the JDBC Driver in version 7.02

On Tue, Jul 11, 2000 at 12:05:29AM +0100, Peter Mount wrote:

----- Original Message -----
From: Joseph Shraibman <jks@selectacast.net>
To: Justin Jaynes <justinjaynes@hotmail.com>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, July 10, 2000 9:57 PM
Subject: Re: [GENERAL] Using the JDBC Driver in version 7.02

Justin Jaynes wrote:

the line:

Class.forName("org.postgresql.Driver");

Try:

Class.forName("postgresql.Driver");

No, this won't work. As of 7.0 it's org.postgresql.Driver

Ofcource, check that postgresql.jar is in classpath. If Java >= 1.2,
you can instead drop it in $JAVA_HOME/jre/lib/ext.

This is the most likely reason it's not working.

Show quoted text

I get an error that the DriverManager cannot find a suitable driver.

The code I use to connect goes as follows:

Connection chamber = DriverManager.getConnection("localhost:5432");

This isn't a valid JDBC URL. You'll need something like:

jdbc:postgresql:database <= Use when on local host
jdbc:postgresql://server/database <= Use when on remote host

--
marko