pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Danish Siddiqui <dsiddiqui@vertex.co.in>
To: pgsql-jdbc@postgresql.org
Subject: Error while trying to connect to postgresql
Date: Fri, 29 Dec 2006 12:45:19 +0530
Message-ID: <4594C087.6040204@vertex.co.in> (raw)

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



view thread (4+ messages)  latest in thread

Message-ID: <4594C087.6040204@vertex.co.in>
Permalink:  ../4594C087.6040204@vertex.co.in/
Also on:    postgresql.org/message-id/4594C087.6040204@vertex.co.in

 · 

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: dsiddiqui@vertex.co.in
  Subject: Re: Error while trying to connect to postgresql
  In-Reply-To: <4594C087.6040204@vertex.co.in>
  References: <4594C087.6040204@vertex.co.in>

* 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