Thread: Problems using JDBC Driver.

Problems using JDBC Driver.

From
Javier Benito
Date:
Hi, i'm starting to use PostgreSQL. I'm using 6.5.4 version, and i'm
having problems using JDBC driver. I'm sure that i'm doing something
wrong but i don't know how. I'm trying to connect to a database in this
way:

                String url = "jdbc:postgresql:BDPrueba";

                Connection con = DriverManager.getConnection(url,"","");

where BDPrueba is the database which i want to connect. The driver is
installed sucessfully, because the Class.forName(postgresql.Driver)
sentence doesn't reach ClassNotFoundException. What can I do?.

Thanks a lot.
Javi.

PD: Sorry if i haven't written this very well, but my english isn't very
good.

Attachment

Re: Problems using JDBC Driver.

From
Tom Cook
Date:
On Wed, 19 Apr 2000, Javier Benito wrote:

> Hi, i'm starting to use PostgreSQL. I'm using 6.5.4 version, and i'm
> having problems using JDBC driver. I'm sure that i'm doing something
> wrong but i don't know how. I'm trying to connect to a database in this
> way:
>
>                 String url = "jdbc:postgresql:BDPrueba";
>
>                 Connection con = DriverManager.getConnection(url,"","");
>
> where BDPrueba is the database which i want to connect. The driver is
> installed sucessfully, because the Class.forName(postgresql.Driver)
> sentence doesn't reach ClassNotFoundException. What can I do?.
>
> Thanks a lot.
> Javi.
>
> PD: Sorry if i haven't written this very well, but my english isn't very
> good.

Your English is fine, but you haven't actually described what it does
wrong. A few things though:

o Your URL looks wrong. I think it should be "jdbc:postgresql://BDPrueba".
o I think it fairly unlikely, although possible, that no username and
  password are required, but I guess you know what's correct for your
  instance.
o Make sure you start the postmaster with the -i switch so that it listens
  on tcp sockets, not just UDP. I think this is necessary for JDBC; it is
  certainly necessary for ODBC, and it took me four or five hours to work
  out that this was my problem.

Send us some more details of what actually goes wrong, like 'it throws
exception x' or 'this statement just sits there doing nothing,' rather
than, 'I'm having problems using JDBC driver.' Code snippet is good,
though - wish more people would do that!

Cheers
--
Tom Cook - Software Engineer

"Christ died for sin, the righteous for the unrighteous, to bring you to God."
    - 1 Peter 3:18

LISAcorp - www.lisa.com.au

--------------------------------------------------
38 Greenhill Rd.          Level 3, 228 Pitt Street
Wayville, SA, 5034        Sydney, NSW, 2000

Phone:   +61 8 8272 1555  Phone:   +61 2 9283 0877
Fax:     +61 8 8271 1199  Fax:     +61 2 9283 0866
--------------------------------------------------