Re: Still baffled by a CONNECTion problem - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: Still baffled by a CONNECTion problem
Date
Msg-id 7802F6D7-4F91-4327-988B-1006EEEADC34@fastcrypt.com
Whole thread Raw
In response to Still baffled by a CONNECTion problem  ("Peter Cook" <ttpcook@hotmail.com>)
List pgsql-jdbc
Peter,

1) You need to specify the jar in the classpath, not just the directory.

ie CLASSPATH=...;C:\Program Files\PostgreSQL\8.0\jdbc
\postgresql-8.0-311.jdbc3.jar

2) locate the postgresql.conf file and edit this to enable a
connection to be made, I believe you need to change listen_address to
'*'

Dave
On 8-Oct-05, at 3:34 AM, Peter Cook wrote:

> It appears my first appeal for help wasn’t clear enough.
>
> I want to connect my Java Application running on Windows 2000 to my
> postgresql database.
>
> From what I understand and have read there are AT LEAST 2 things I
> need to do.
>
> (1) Have the application load the relevant JDBC driver and
>
> (2) Make a connection.
>
> With respect to (1), despite numerous attempts I have been unable
> to resolve the ClassNotFound exception.
>
> I have set the CLASSPATH environment variable as follows:
> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:
> \PROGRA~1\ULTRAE~1;C:\Program Files\Java\jdk1.5.0_04\bin;C:\Program
> Files\PostgreSQL\8.0\jdbc
>
> I have written some test code in Java to load the Driver, as follows:
>     public void displayClasspath()
>     {
>         String driverPath = "C:\\Program Files\\PostgreSQL\\8.0\
> \jdbc";
>         String classpath = System.getProperty("java.class.path");
>         _displayTextArea.append("Classpath = " + classpath + "\n");
>
>         classpath = classpath + ";" + driverPath + "\
> \postgresql-8.0-311.jdbc3.jar";
>         System.setProperty("java.class.path", classpath);
>         _displayTextArea.append("Classpath = " + classpath + "\n");
>
>         System.setProperty("jdbc.drivers", driverPath);
>         String drivers = System.getProperty("jdbc.drivers");
>         _displayTextArea.append("Drivers = " + drivers + "\n");
>
>         // 1. Load the jdbc.odbc database driver class
>        try
>        {
>            File driverDir = new File(driverPath);
>            if ( driverDir.isDirectory() )
>                _displayTextArea.append("DriverDir is a directory \n");
>            else
>                _displayTextArea.append("DriverDir is NOT a
> directory \n");
>
>            File dFile = new File(driverPath + "\\org\\postgresql\
> \Driver.class");
>            if ( dFile.isFile() )
>                _displayTextArea.append("Driver is a file \n");
>            else
>                _displayTextArea.append("Driver is NOT a file \n");
>
>            String driver = "org.postgresql.Driver";
>            driverPath = driverPath + "\\" + driver;
>
>            Class.forName(driver);
>        }
>         catch (ClassNotFoundException cnfe)
>         {
>             System.out.println("ClassNotFoundException.");
>        }
>     }
>
> The output from this code is as follows:
> Classpath = C:\Eclipse\Workspace\Test
> Classpath = C:\Eclipse\Workspace\Test;C:\Program Files\PostgreSQL
> \8.0\jdbc\postgresql-8.0-311.jdbc3.jar
> Drivers = C:\Program Files\PostgreSQL\8.0\jdbc
> DriverDir is a directory
> Driver is a file
>
> So:
> - for some unknown reason my Eclipse editor has reset my CLASSPATH
> - but despite this I am able to programmatically adjust the
> CLASSPATH property to suit
> - Java recognized the directory where I have installed the JAR file
> as a valid directory and is able to locate the relevant driver file
>
> WHY WON’T IT LOAD the DRIVER?????
>
>
> With respect to (2) creating a connection.
> From what I have read I need to set the PostMaster to run with a “-
> I” flag to enable TCP/IP communication.
> However the Postmaster is started somewhere in the boot sequence,
> and I don’t know how to adjust it’s startup.
>
> HOW DO I DO THIS?
>
>
> IS THERE SOMETHING ELSE I NEED TO DO???
>
> I think I can work out the connection parameters and make the
> connection IF I CAN RESOLVE THESE QUESTIONS.
>
> Yours Sincerely
>
> Peter Cook
>
> _________________________________________________________________
> REALESTATE: biggest buy/rent/share listings   http://
> ninemsn.realestate.com.au
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>


pgsql-jdbc by date:

Previous
From: "Peter Cook"
Date:
Subject: Still baffled by a CONNECTion problem
Next
From: Oliver Jowett
Date:
Subject: Re: Still baffled by a CONNECTion problem