Skip site navigation (1) Skip section navigation (2)

Re: JDBC connection issue

From: Blaine Simpson <blaine(dot)simpson(at)admc(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC connection issue
Date: 2004-07-21 21:47:56
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Use "md5" instead of "trust".  Besides trust having all sorts of 
problems to do
with ident daemons, I don't even know if the JDBC driver will work with 
since JDBC network drivers generally pass a username and password.  First
get psql working locally before trying to get the JDBC driver to work, like

    psql -h hostname -U blaine dbname

Here's a typical md5 record:

    host    all         all     md5

Where, as you probably know, is the permitted
source IP range.

I've worked with about a dozen network JDBC drivers over the past several
years, as a driver developer and a user.  Contrary to what some 
Java-phobes say,
JDBC drivers are very easy to use directly from Java clients.  The
difficulty comes when vendors build shitty abstraction, pooling, and
management functions to isolate your code from the JDBC drivers.  Load
your JDBC driver directly with your own code and everything is simple.

I recommend you try my SqlTool client as a utility to get your setup 

>>I am having some difficulties connecting to a local postgresql database via
>> jdbc driver.
>>my setup is:
>>mandrake 10.0
>>postgresql 7.4.3
>>I've configured postgresql from its source with --with-java option, make, a
>>nd make install.
>>The default directory for the postgresql.jar is /usr/local/pgsql/share/java
>>I've run >jar -tf /usr/local/pgsql/share/java/postgresql.jar and the class 
>>files seem to be in the right order.
>>I've added the following line to the pg hba.conf to test local connections 
>>via jdbc driver.
>>local	all	all	trust
>>Also, changed the postgresql.conf
>>tcpip socket = true
>>Added CLASSPATH to bashrc file
>>export CLASSPATH=/usr/local/pgsql/share/java/postgresql.jar:${CLASSPATH}
>>and I am trying to run the following code
>>import java.sql.*;
>>import java.util.*;
>>public class Xlang {
>>	public static void main(String[] args) {
>>		try {
>>			Class.forName("org.postgresql.Driver");
>>		...
>>	}
>>and I am getting the following exception..
>>java.lang.ClassNotFoundException: org.postgresql.Driver
>>Any ideas would be very much appreciated.
>>---------------------------(end of broadcast)---------------------------
>>TIP 9: the planner will ignore your desire to choose an index scan if your
>>      joining column's datatypes do not match

ICF:  703-934-3692       Cell:  703-944-9317

In response to


pgsql-jdbc by date

Next:From: Kris JurkaDate: 2004-07-21 22:14:11
Subject: Re: JDBC connection issue
Previous:From: Oliver JowettDate: 2004-07-21 21:20:55
Subject: Re: V3 protocol + DECLARE problems

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group