pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
jdbc connection issue in 8.0.3
2+ messages / 2 participants
[nested] [flat]

* jdbc connection issue in 8.0.3
@ 2005-07-27 16:26 sankaran nambi <snambi_75@yahoo.com>
  2005-07-27 16:52 ` Re: jdbc connection issue in 8.0.3 Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 2+ messages in thread

From: sankaran nambi @ 2005-07-27 16:26 UTC (permalink / raw)
  To: 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       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
 

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: jdbc connection issue in 8.0.3
  2005-07-27 16:26 jdbc connection issue in 8.0.3 sankaran nambi <snambi_75@yahoo.com>
@ 2005-07-27 16:52 ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Cramer @ 2005-07-27 16:52 UTC (permalink / raw)
  To: sankaran nambi <snambi_75@yahoo.com>; +Cc: pgsql-jdbc

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
>

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-07-27 16:52 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-27 16:26 jdbc connection issue in 8.0.3 sankaran nambi <snambi_75@yahoo.com>
2005-07-27 16:52 ` Dave Cramer <pg@fastcrypt.com>

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