X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2DDE852E81 for ; Wed, 27 Jul 2005 13:26:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03120-02 for ; Wed, 27 Jul 2005 16:26:37 +0000 (GMT) Received: from web54108.mail.yahoo.com (web54108.mail.yahoo.com [206.190.37.243]) by svr1.postgresql.org (Postfix) with SMTP id 0BF6652C2C for ; Wed, 27 Jul 2005 13:26:36 -0300 (ADT) Received: (qmail 86339 invoked by uid 60001); 27 Jul 2005 16:26:32 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=e5/NxMbtOPJS/1ydGM8Us/gOP5dAuR3zCstLEINd0ueuFag/5jCPDJkTBkA/bFgHp0c8uHI0qQUE+18bs0Dq77yKO18QsKXfKH2ebTs4G+0RggweWCn5kUksDsqpZ3oUZ2LKu+kIyOLvdwuuE2uplGhxCCwgKYGXKRBAHiodu+Q= ; Message-ID: <20050727162632.86337.qmail@web54108.mail.yahoo.com> Received: from [24.6.135.150] by web54108.mail.yahoo.com via HTTP; Wed, 27 Jul 2005 09:26:32 PDT Date: Wed, 27 Jul 2005 09:26:32 -0700 (PDT) From: sankaran nambi Subject: jdbc connection issue in 8.0.3 To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1751612894-1122481592=:86330" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.612 tagged_above=0 required=5 tests=FROM_ENDS_IN_NUMS, HTML_50_60, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200507/370 X-Sequence-Number: 13518 --0-1751612894-1122481592=:86330 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 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 http://opentrade.sf.net --0-1751612894-1122481592=:86330 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
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
 
http://opentrade.sf.net
 
--0-1751612894-1122481592=:86330--