pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Still baffled by a CONNECTion problem
3+ messages / 3 participants
[nested] [flat]

* Still baffled by a CONNECTion problem
@ 2005-10-08 07:34  Peter Cook <ttpcook@hotmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Peter Cook @ 2005-10-08 07:34 UTC (permalink / raw)
  To: pgsql-jdbc

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.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Still baffled by a CONNECTion problem
@ 2005-10-08 08:11  Dave Cramer <pg@fastcrypt.com>
  parent: Peter Cook <ttpcook@hotmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Dave Cramer @ 2005-10-08 08:11 UTC (permalink / raw)
  To: Peter Cook <ttpcook@hotmail.com>; +Cc: 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
>
>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Still baffled by a CONNECTion problem
@ 2005-10-08 09:47  Oliver Jowett <oliver@opencloud.com>
  parent: Peter Cook <ttpcook@hotmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Oliver Jowett @ 2005-10-08 09:47 UTC (permalink / raw)
  To: Peter Cook <ttpcook@hotmail.com>; +Cc: pgsql-jdbc

Peter Cook wrote:

>         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?????

Your sample output did not include the ClassNotFoundException output, so
it seems to me that the driver actually loaded fine?

-O



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-10-08 09:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-08 07:34 Still baffled by a CONNECTion problem Peter Cook <ttpcook@hotmail.com>
2005-10-08 08:11 ` Dave Cramer <pg@fastcrypt.com>
2005-10-08 09:47 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox