Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 3920C9FA18F for ; Fri, 29 Dec 2006 05:07:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 09537-09 for ; Fri, 29 Dec 2006 05:07:18 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.173]) by postgresql.org (Postfix) with ESMTP id 309249FA102 for ; Fri, 29 Dec 2006 05:07:21 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so1036691ugf for ; Fri, 29 Dec 2006 01:07:19 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:x-enigmail-version:content-type:content-transfer-encoding:sender; b=Uw//ZRHBqBI0kaKJgzTcfJH2myndCjnrlImZA91cMdWqSmduKvm1LtARz1DRmZJ9n94kTt/pjGlxNZ7x9GGNX9RqBHTs1+5kd2XrJxrou4hTMxmTcXHYCF1Qy1PmX5QBELa44nF3R9Aj0WdiHI4pKnCSSYBqAPvTaVvbRVM2GKU= Received: by 10.67.92.1 with SMTP id u1mr5004855ugl.1167383239094; Fri, 29 Dec 2006 01:07:19 -0800 (PST) Received: from ?192.168.1.33? ( [82.247.148.168]) by mx.google.com with ESMTP id 54sm25727993ugp.2006.12.29.01.07.18; Fri, 29 Dec 2006 01:07:18 -0800 (PST) Message-ID: <4594DAC3.5020004@free.fr> Date: Fri, 29 Dec 2006 10:07:15 +0100 From: "Xavier Poinsard" User-Agent: Thunderbird 1.5.0.8 (X11/20061115) MIME-Version: 1.0 To: Danish Siddiqui CC: pgsql-jdbc@postgresql.org Subject: Re: Error while trying to connect to postgresql References: <4594C087.6040204@vertex.co.in> In-Reply-To: <4594C087.6040204@vertex.co.in> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/127 X-Sequence-Number: 16359 Hi, Your url is wrong. It should look like "jdbc:postgresql://localhost/postgres". See http://jdbc.postgresql.org/documentation/82/connect.html for more info. Regards. Danish Siddiqui a écrit : > Hi, > Can some one help me out with this problem. Ive been searching around > for some help but couldnt find any... > > Im trying to connect PostgreSQL with Java.. > > import java.sql.*; > > class PostgreSQLTest{ > public static void main(String[] args){ > Class.forName("org.postgresql.Driver"); > String url="jdbcostgresql://localhost/postgres"; > Connection db = DriverManager.getConnection("url", "postgres", ""); > > System.out.println("Connection Created"); > db.close(); > } > } > > # javac PostgreSQLTest.java > > PostgreSQLTest.java:5: unreported exception > java.lang.ClassNotFoundException; must be caught or declared to be thrown > Class.forName("org.postgresql.Driver"); > ^ > PostgreSQLTest.java:7: unreported exception java.sql.SQLException; must > be caught or declared to be thrown > Connection db = DriverManager.getConnection("url", "postgres", ""); > ^ > PostgreSQLTest.java:10: unreported exception java.sql.SQLException; must > be caught or declared to be thrown > db.close(); > ^ > 3 errors > > > # echo $CLASSPATH > :/usr/local/jdk1.6.0/lib/tools.jar:/usr/local/pgsql/share/java/postgresql-8.1-408.jdbc3.jar:/usr/local/jdk1.6.0/lib/:/home/danish/:/home/danish/PostgreSQLTest.java > > > Thanks > Danish > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org >