Re: JDBC connection issue - Mailing list pgsql-jdbc

From Blaine Simpson
Subject Re: JDBC connection issue
Date
Msg-id 40FEE48C.3010208@admc.com
Whole thread Raw
In response to Re: JDBC connection issue  (foredl@yahoo.com (datalines))
Responses Re: JDBC connection issue
List 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
ident,
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         192.168.100.0     255.255.255.0     md5

Where, as you probably know, 192.168.100.0/255.255.255.0 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
working.
http://hsqldb.sourceforge.net/guide/ch07.html

>>Hi,
>>
>>I am having some difficulties connecting to a local postgresql database via
>> jdbc driver.
>>
>>my setup is:
>>mandrake 10.0
>>j2sdk1.4.2
>>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
>>/postgresql.jar
>>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    127.0.0.1    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.
>>
>>YJ
>>
>>---------------------------(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


pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: V3 protocol + DECLARE problems
Next
From: Kris Jurka
Date:
Subject: Re: JDBC connection issue