Getting connected

From: "Peter Cook" <ttpcook(at)hotmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Getting connected
Date: 2005-10-06 05:06:06
Message-ID: BAY103-F40117189CA6BE61B278236B7850@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I have a Java Application running on Windows 2000.

Initially it accessed an Access database, and now that I have installed
postgreSQL, I want to configure it to access postgreSQL.

Is there a single document that can take me through the steps, or can
someone give me a simple checklist of what I need to do?????

I have downloaded the JDBC driver and I know:
- the driver class exists at "C:\Program Files\PostgreSQL\8.0\jdbc";
- it is in a JAR file ( I unpacked the JAR file, only to realise I didn't
need to )

However my code throws a ClassNotFound exception.
Below is some code I wrote to test and set property values, and to check
whether the driver directory and driver.class exist.

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;
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");

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(driverPath);
}
catch (ClassNotFoundException cnfe)
{
System.out.println("ClassNotFoundException.");
}
}

This code produces these messages:
Classpath = C:\Eclipse\Workspace\Test
Classpath = C:\Eclipse\Workspace\Test;C:\Program Files\PostgreSQL\8.0\jdbc
Drivers = C:\Program Files\PostgreSQL\8.0\jdbc
DriverDir is a directory
Driver is a file

Yet whether I use:
Class.forName(driverPath)
OR
Class.forName(driver)
it throws a ClassNotFoundException

I believe the Postmaster needs to be started with a -I option to enable
TCP/IP communication between application and server.
However it appears that the Postmaster is started in the boot sequence
somewhere, and I dont know where I need to make this adjustment.

I would appreciate your help.

Yours sincerely

Peter Cook

_________________________________________________________________
Sell your car for $9 on carpoint.com.au
http://www.carpoint.com.au/sellyourcar

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Alfredo Rico 2005-10-06 13:27:28 I have a problem of abstraction...
Previous Message Dave Cramer 2005-10-05 23:20:31 Re: "org.postgresql.util.PSQLException: This ResultSet is