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 A753F52E61 for ; Wed, 27 Jul 2005 13:52:35 -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 07677-07 for ; Wed, 27 Jul 2005 16:52:30 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 3BF9052B80 for ; Wed, 27 Jul 2005 13:52:28 -0300 (ADT) Received: (qmail 6303 invoked from network); 27 Jul 2005 16:52:28 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 27 Jul 2005 16:52:28 -0000 In-Reply-To: <20050727162632.86337.qmail@web54108.mail.yahoo.com> References: <20050727162632.86337.qmail@web54108.mail.yahoo.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: multipart/alternative; boundary=Apple-Mail-24-294542588 Message-Id: <19214231-AD85-4A53-9B90-FE44A5E244EA@fastcrypt.com> Cc: pgsql-jdbc@postgresql.org From: Dave Cramer Subject: Re: jdbc connection issue in 8.0.3 Date: Wed, 27 Jul 2005 12:52:26 -0400 To: sankaran nambi X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, HTML_40_50, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200507/371 X-Sequence-Number: 13519 --Apple-Mail-24-294542588 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed 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 > --Apple-Mail-24-294542588 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 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
=A0
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.
=A0
# "local" is for Unix domain socket connections = only
local=A0=A0 all=A0=A0=A0=A0=A0=A0=A0=A0 = all=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0 md5
# IPv4 local = connections:
host=A0=A0=A0 all=A0=A0=A0=A0=A0=A0=A0=A0 all=A0=A0=A0=A0=A0= =A0=A0=A0 127.0.0.1=A0=A0=A0255.255.255.255=A0=A0 md5
# IPv6 local = connections:
host=A0=A0=A0 all=A0=A0=A0=A0=A0=A0=A0=A0 all=A0=A0=A0=A0=A0= =A0=A0=A0 ::1/128=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0= =A0=A0 md5
#nossl for tcp/ip sockets
hostnossl all=A0=A0=A0=A0&n= bs p;=A0 all=A0=A0=A0=A0=A0=A0=A0=A0 127.0.0.1=A0=A0=A0255.255.255.255=A0=A0= 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.
=A0
-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=A0=A0= =A0=A0 STATE SERVICE
5432/tcp open=A0 = 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=A0java (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
{
=A0=A0=A0 = private String loginUser =3D "snambi";
=A0=A0=A0 private String = loginPasswd =3D "test123";
=A0=A0=A0 private String loginUrl =3D = "jdbc:postgresql://localhost/brokerdb";
=A0=A0=A0 private Connection connection = =3D null;
=A0=A0=A0= void DB()
=A0=A0=A0 {}
=A0=A0=A0 void connect()
=A0=A0=A0 {
=A0=A0=A0=A0=A0= =A0=A0 createConnection( loginUser, loginPasswd, loginUrl );
=A0=A0=A0 = }
=A0=A0=A0 = void createConnection( String user, String passwd, String url )
=A0=A0=A0= {
=A0=A0=A0=A0=A0=A0=A0 try
=A0=A0=A0=A0=A0=A0=A0 = {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Driver driver =3D (Driver) = Class.forName("org.postgresql.Driver").newInstance();
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 System.out.println("Does that driver like my url? " + = driver.acceptsURL( url ) );
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 connection =3D = DriverManager.getConnection( user, passwd, url );
=A0=A0=A0=A0=A0=A0=A0= }
=A0=A0=A0=A0=A0=A0=A0 catch( Exception e )
=A0=A0=A0=A0=A0=A0=A0 = {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = e.printStackTrace();
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = System.out.println("Error Connecting to Database " + e.getMessage() = );
=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0 }
=A0=A0=A0 public static void main( = String[] args )
=A0=A0=A0 {
=A0=A0=A0=A0=A0=A0=A0 DB db =3D new = DB();
=A0=A0=A0=A0= =A0=A0=A0 db.connect();
=A0=A0=A0 }
}
=
=A0
=
=A0
=
The output of this program is = ,
=A0
=
=A0
=A0
=A0
$java = broker.DB
Does that driver like my url? = true
java.sql.SQLException: No suitable driver
=A0=A0=A0=A0=A0=A0=A0= at = java.sql.DriverManager.getConnection(DriverManager.java:545)
=A0=A0=A0=A0= =A0=A0=A0 at = java.sql.DriverManager.getConnection(DriverManager.java:171)
=A0=A0=A0=A0= =A0=A0=A0 at broker.DB.createConnection(DB.java:31)
=A0=A0=A0=A0=A0=A0=A0= at broker.DB.connect(DB.java:21)
=A0=A0=A0=A0=A0=A0=A0 at = broker.DB.main(DB.java:44)
Error Connecting to Database No suitable = driver
the classpath contains the jdbc = driver.
=A0
=
$echo = $CLASSPATH
:.:/home/snambi/otp/software/je-1.7.1/lib/je.jar:/ho= me/snambi/otp/software//postgresql-8.0-312.jdbc3.jar:/home/snambi= /otp/software/commons-collections-3.1/commons-collections-3.1.jar:/home/sn= ambi/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/activem= q-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/geron= imo-spec-jta-1.0.1B-rc4.jar:/home/snambi/otp/software/activemq-3.0/lib/ger= onimo-spec-jms-1.1-rc4.jar:/home/snambi/otp/software/activemq-3.0/lib/gero= nimo-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.
=A0
thanks,
nambi
=A0
=
=A0
= --Apple-Mail-24-294542588--