pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: sankaran nambi <snambi_75@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: jdbc connection issue in 8.0.3
Date: Wed, 27 Jul 2005 12:52:26 -0400
Message-ID: <19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com> (raw)
In-Reply-To: <20050727162632.86337.qmail@web54108.mail.yahoo.com>
References: <20050727162632.86337.qmail@web54108.mail.yahoo.com>

Took me a while, but you have getConnection(user, password,url)

s/b getConnection(url, user, password);

--dc--
On 27-Jul-05, at 12:26 PM, sankaran nambi wrote:

> 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
>

view thread (2+ messages)

Message-ID: <19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com>
Permalink:  ../19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com/
Also on:    postgresql.org/message-id/19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, snambi_75@yahoo.com
  Subject: Re: jdbc connection issue in 8.0.3
  In-Reply-To: <19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com>
  References: <20050727162632.86337.qmail@web54108.mail.yahoo.com> <19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox