Java Postgres drivers.

Started by Dave Coventryover 16 years ago6 messagesgeneral
Jump to latest
#1Dave Coventry
dgcoventry@gmail.com

I'm not sure this is the right place to enquire...

I'm trying to connect to a postgres datanbase with Java.

import java.sql.*;

public static void main(String[] args) {
// TODO code application logic here
try{
System.out.println("Starting...");
Class.forName("org.postgresql.Driver");
String url="jdbc:postgresql:inenergy";
System.out.println("Got here...");

catch(Exception e){
System.out.println("Error..."+e.getMessage());

}
}

Just don't get to the 'Got here...' statement.

Can anyone see what I'm doing wrong?

#2John R Pierce
pierce@hogranch.com
In reply to: Dave Coventry (#1)
Re: Java Postgres drivers.

Dave Coventry wrote:

I'm not sure this is the right place to enquire...

I'm trying to connect to a postgres datanbase with Java.

does that sample code hang? do you get an error?

#3Ivano Luberti
luberti@archicoop.it
In reply to: Dave Coventry (#1)
Re: Java Postgres drivers.

Sure the url looks bad.
Shoudl be something like:

http://jdbc.postgresql.org/dbname

Anyway you cen find more help about jdbc connectivity to postgres here:

http://jdbc.postgresql.org/

Dave Coventry ha scritto:

I'm not sure this is the right place to enquire...

I'm trying to connect to a postgres datanbase with Java.

import java.sql.*;

public static void main(String[] args) {
// TODO code application logic here
try{
System.out.println("Starting...");
Class.forName("org.postgresql.Driver");
String url="jdbc:postgresql:inenergy";
System.out.println("Got here...");

catch(Exception e){
System.out.println("Error..."+e.getMessage());

}
}

Just don't get to the 'Got here...' statement.

Can anyone see what I'm doing wrong?

--
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================

#4Noname
fernando@lozano.eti.br
In reply to: Ivano Luberti (#3)
Re: Java Postgres drivers.

Dave,

It looks like the postgresql.jar archive is not in your CLASSPATH.

[]s, Fernando Lozano

Show quoted text

I'm not sure this is the right place to enquire...

I'm trying to connect to a postgres datanbase with Java.

import java.sql.*;

public static void main(String[] args) {
// TODO code application logic here
try{
System.out.println("Starting...");
Class.forName("org.postgresql.Driver");
String url="jdbc:postgresql:inenergy";
System.out.println("Got here...");

catch(Exception e){
System.out.println("Error..."+e.getMessage());

}
}

Just don't get to the 'Got here...' statement.

Can anyone see what I'm doing wrong?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5John R Pierce
pierce@hogranch.com
In reply to: Ivano Luberti (#3)
Re: Java Postgres drivers.

Ivano Luberti wrote:

Sure the url looks bad.
Shoudl be something like:

http://jdbc.postgresql.org/dbname

say huh?

http://jdbc.postgresql.org/documentation/84/load.html
http://jdbc.postgresql.org/documentation/84/connect.html

says what he's doing is fine.

#6Ivano Luberti
luberti@archicoop.it
In reply to: John R Pierce (#5)
Re: Java Postgres drivers.

Oh sorry, cut and paste mistake
By the way using that syntax he is using he is assuming the server is
running on localhost and the port is the default one

John R Pierce ha scritto:

Ivano Luberti wrote:

Sure the url looks bad.
Shoudl be something like:

http://jdbc.postgresql.org/dbname

say huh?

http://jdbc.postgresql.org/documentation/84/load.html
http://jdbc.postgresql.org/documentation/84/connect.html

says what he's doing is fine.

--
==================================================
dott. Ivano Mario Luberti
Archimede Informatica societa' cooperativa a r. l.
Sede Operativa
Via Gereschi 36 - 56126- Pisa
tel.: +39-050- 580959
tel/fax: +39-050-9711344
web: www.archicoop.it
==================================================