Re: Newbie: connecting from windows to Linux: how-to?

Lists: pgsql-jdbc
From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Newbie: connecting from windows to Linux: how-to?
Date: 2002-10-09 06:33:10
Message-ID: 3DA3CDA6.1060701@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

I'm sure this question must have been asked before but I cannot find it
in the archives. If this is the wrong ML to ask please let me know.

I have PostgreSQL running on a Linux box and now I would like to build a
Java GUI tool to access/modify the data.

I'm guessing the first thing I need to learn how to do in Java is how to
connect from the windows machine to the Linux pg DB.

I've read http://jdbc.postgresql.org/doc.html about downloading and
installing the JDBC driver but I don't see any instructions relating on
how to do this in windows ...

Can someone explain to me or point me to a document that explains the
steps I need to take in order to establish a connection in Java from
windows to PostgreSQL running on a linux box?

Thanks!

Jc


From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: Laszlo Hornyak <hornyakl(at)rootshell(dot)be>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Newbie: connecting from windows to Linux: how-to?
Date: 2002-10-09 08:00:44
Message-ID: 3DA3E22C.9020403@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Laszlo Hornyak wrote:
>
> Check your $CLASSPATH, you need a postgresql.jar in it.

Where do I get that jar from? I was able to download a "pgjdbc2.jar"
which is supposed to be the JDBC driver from the PostgreSQl site but I
could not find any postgresql.jar file anywhere ....

Also ... the install instructions call for "make" and stuff. I'm on
Windows ...

Jc


From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: Laszlo Hornyak <hornyakl(at)rootshell(dot)be>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Newbie: connecting from windows to Linux: how-to?
Date: 2002-10-09 10:11:17
Message-ID: 3DA400C5.3020505@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Laszlo Hornyak wrote:
> As much as I know Pg doesn`t build on windows. Maybe try it on linux.
>
> to check a jar file:
> jar tf jarfile.jar
> if you see the class file, it is ok.

I'm using Pg on Linux but Java on Windows. The jar file seems fine using
the command you gave.

I did check that Pg is running with IP on ...

$ netstat -an | grep 5432 | grep LISTEN
unix 2 [ ACC ] STREAM LISTENING 1347 /tmp/.s.PGSQL.5432

I tried the test program suggested in the link given by Joe Shevland and
everything seems to be fine except for my connection string.

I have tried these various connection strings:

Connection c = null;

c1 =
DriverManager.getConnection("jdbc:postgresql://192.168.254.14/JC","postgres","");
c2 =
DriverManager.getConnection("jdbc:postgresql://192.168.254.14:5432/JC","postgres","");

And get this error for both strings:

Checking if Driver is registered with DriverManager.
Couldn't find the driver!
Let's print a stack trace, and exit.
java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at Example1.main(Example1.java:10)
Jc


From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: Laszlo Hornyak <hornyakl(at)rootshell(dot)be>, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Newbie: connecting from windows to Linux: how-to?
Date: 2002-10-09 10:46:23
Message-ID: 3DA408FF.5030705@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Laszlo Hornyak wrote:
>
> Simply java doesn`t find the driver classes.
> What does the following say?

Oops ... I posted the wrong ouput ... the driver class is being found (I
think, since it is being registered). Maye I need InstanceOf()? Here is
the error message I get:

D:\java>java -cp .;pgjdbc2.jar Example1
Checking if Driver is registered with DriverManager.
Registered the driver ok, so let's make a connection.
Couldn't connect: print out a stack trace and exit.
Connection refused. Check that the hostname and port is correct, and
that the postmaster is running with the -i flag, which enables TCP/IP
networking.
at org.postgresql.Connection.openConnection(Connection.java:141)
at org.postgresql.Driver.connect(Driver.java:149)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Example1.main(Example1.java:26)

> set %CLASSPATH

CLASSPATH=.;d\j2sdk1.4.1

Jc


From: Aaron Mulder <ammulder(at)alumni(dot)princeton(dot)edu>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Newbie: connecting from windows to Linux: how-to?
Date: 2002-10-09 11:11:21
Message-ID: Pine.LNX.4.44.0210090709280.24044-100000@www.princetongames.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Wed, 9 Oct 2002, Jean-Christian Imbeault wrote:
> I did check that Pg is running with IP on ...
>
> $ netstat -an | grep 5432 | grep LISTEN
> unix 2 [ ACC ] STREAM LISTENING 1347 /tmp/.s.PGSQL.5432

But this means it's *not* running with IP -- it's running with
UNIX sockets, which is how it handles non-network requests. If you try
"telnet serverhostname 5432", I would expect you'd get a connection
refused message.

Aaron