RE: JDBC connection - DB Prep?

From: "Culberson, Philip" <philip(dot)culberson(at)dat(dot)com>
To: "'gauss'" <carlga(at)mail(dot)ohusc(dot)k12(dot)in(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: RE: JDBC connection - DB Prep?
Date: 2000-04-11 15:20:42
Message-ID: A95EFC3B707BD311986C00A0C9E95B6A9DE641@datmail03.dat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Diagnosing your problem is a little more difficult because you are trapping
any exceptions. It would help narrow the possible causes if you would put a
"ex.printStackTrace();" in the catch clause. That said, here are a couple
possibilities:

1) Is the postgresql.jar in your CLASSPATH?

2) Have you configured $PGDATA/pg_hba.conf to allow connections from your
client machine? You would need a line similar to:

host midterm 123.456.789.01 255.255.255.0 trust
^^^^^^^^^^^^^^
IP of client machine here

3)Are you sure user "bryon" is a valid Postgres user? You would have had to
either install Postgres as "bryon", or have run the "createuser" script.

Hope some of this helps.

Phil Culberson
DAT Services

-----Original Message-----
From: gauss [mailto:carlga(at)mail(dot)ohusc(dot)k12(dot)in(dot)us]
Sent: Tuesday, April 11, 2000 5:37 AM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] JDBC connection - DB Prep?

I have a PGSQL 6.5.2 running on redhat linux and am trying to connect to it
from a remote machine. I have the DB and table created and can access the
table at the console ("pgsql midterm" midterm=>).

when I run SimpleExample.class the first three println statments display.
The fourth does not. I think I have my code right. How do I verify that
Postgresql is accepting connections. I can "ping" the machine that
Posgresql is on.

I know that postmaster needs to be started with the -i. How do I verify
this with the default installation of PGSQL when Linux is installed. What
else do I need to do to prepare the database for connection through JDBC?

Here is my Java code:

import java.sql.*;

class SimpleExample{
public static void main(String[] args) {
System.out.println("before the try");
try
{
String url =
"jdbc:postgresql://172.20.50.25/midterm";
System.out.println("before the Class.forName
statement");
Class.forName("postgresql.Driver");
System.out.println("before the Connection
statement");
Connection myConnection =
DriverManager.getConnection(url, "bryon", "1234");
System.out.println("Connection is open");

if (!myConnection.isClosed())
{myConnection.close();}

}
catch (java.lang.Exception ex){}

}
}

Thanks for the help.
Bryon

Browse pgsql-general by date

  From Date Subject
Next Message Ron Peterson 2000-04-11 15:21:08 Re: recursive queries?
Previous Message Culberson, Philip 2000-04-11 14:51:25 RE: Importing a comma-delimited text file