jdbc connection issue in 8.0.3 - Mailing list pgsql-jdbc

From sankaran nambi
Subject jdbc connection issue in 8.0.3
Date
Msg-id 20050727162632.86337.qmail@web54108.mail.yahoo.com
Whole thread Raw
Responses Re: jdbc connection issue in 8.0.3
List pgsql-jdbc
Hi
 
I am new to postgresql. I have installed pgsql server 8.0.3 in Redhat fedora core2. I have updated the pg_hba.conf file, to listen on a plain tcp/ip socket.
 
# "local" is for Unix domain socket connections only
local   all         all                                       md5
# IPv4 local connections:
host    all         all         127.0.0.1   255.255.255.255   md5
# IPv6 local connections:
host    all         all         ::1/128                       md5
#nossl for tcp/ip sockets
hostnossl all    &nbs p;  all         127.0.0.1   255.255.255.255   md5

After doing this, I am able to connect to the server using psql with -h option. Also I can see the pgsql socket in nmap output.
 
-bash-2.05b$ nmap -p5000-6000 localhost
Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2005-07-27 09:18 PDT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1000 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
5432/tcp open  postgres
Nmap run completed -- 1 IP address (1 host up) scanned in 0.376 seconds

However, I couldn't connect to the postgresql server using jdbc and java (1.5). I have listed the code below. it is very simple. it throws the error "No Suitable driver".


import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
class DB
{
    private String loginUser = "snambi";
    private String loginPasswd = "test123";
    private String loginUrl = "jdbc:postgresql://localhost/brokerdb";
    private Connection connection = null;
    void DB()
    {}
    void connect()
    {
        createConnection( loginUser, loginPasswd, loginUrl );
    }
    void createConnection( String user, String passwd, String url )
    {
        try
        {
            Driver driver = (Driver) Class.forName("org.postgresql.Driver").newInstance();
            System.out.println("Does that driver like my url? " + driver.acceptsURL( url ) );
            connection = DriverManager.getConnection( user, passwd, url );
        }
        catch( Exception e )
        {
            e.printStackTrace();
            System.out.println("Error Connecting to Database " + e.getMessage() );
        }
    }
    public static void main( String[] args )
    {
        DB db = new DB();
        db.connect();
    }
}
 
 
The output of this program is ,
 
 
 
 
$java broker.DB
Does that driver like my url? true
java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getConnection(DriverManager.java:545)
        at java.sql.DriverManager.getConnection(DriverManager.java:171)
        at broker.DB.createConnection(DB.java:31)
        at broker.DB.connect(DB.java:21)
        at broker.DB.main(DB.java:44)
Error Connecting to Database No suitable driver
the classpath contains the jdbc driver.
 
$echo $CLASSPATH
:.:/home/snambi/otp/software/je-1.7.1/lib/je.jar:/home/snambi/otp/software//postgresql-8.0-312.jdbc3.jar:/home/snambi/otp/software/commons-collections-3.1/commons-collections-3.1.jar:/home/snambi/otp/software/activemq-3.0/lib/activemq-core-3.0.jar:/home/snambi/otp/software/activemq-3.0/lib/spring-1.1.jar:/home/snambi/otp/software/activemq-3.0/lib/concurrent-1.3.4.jar:/home/snambi/otp/software/activemq-3.0/lib/commons-logging-1.0.3.jar:/home/snambi/otp/software/activemq-3.0/lib/geronimo-spec-jta-1.0.1B-rc4.jar:/home/snambi/otp/software/activemq-3.0/lib/geronimo-spec-jms-1.1-rc4.jar:/home/snambi/otp/software/activemq-3.0/lib/geronimo-spec-j2ee-management-1.0-rc4.jar:/home/snambi/otp/pkgs/otp.jar
I have no idea what is missing.
I'd really appreciate any help in solving this problem.
 
thanks,
nambi
 
 

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: jdbc xa patches
Next
From: Dave Cramer
Date:
Subject: Re: jdbc connection issue in 8.0.3