Skip site navigation (1) Skip section navigation (2)

Re: Error while trying to connect to postgresql

From: "Xavier Poinsard" <xpoinsard(at)free(dot)fr>
To: Danish Siddiqui <dsiddiqui(at)vertex(dot)co(dot)in>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Error while trying to connect to postgresql
Date: 2006-12-29 09:07:15
Message-ID: 4594DAC3.5020004@free.fr (view raw or flat)
Thread:
Lists: pgsql-jdbc
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
> 


In response to

Responses

pgsql-jdbc by date

Next:From: Xavier PoinsardDate: 2006-12-29 09:15:06
Subject: Re: Error while trying to connect to postgresql
Previous:From: Danish SiddiquiDate: 2006-12-29 07:15:19
Subject: Error while trying to connect to postgresql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group