Error while trying to connect to postgresql

Поиск
Список
Период
Сортировка
От Danish Siddiqui
Тема Error while trying to connect to postgresql
Дата
Msg-id 4594C087.6040204@vertex.co.in
обсуждение исходный текст
Ответы Re: Error while trying to connect to postgresql  ("Xavier Poinsard" <xpoinsard@free.fr>)
Re: Error while trying to connect to postgresql  ("Xavier Poinsard" <xpoinsard@free.fr>)
Список pgsql-jdbc
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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Ken Johanson
Дата:
Сообщение: Support for DatabaseMetadata: getCatalogName, getTableName, getColumnLabel
Следующее
От: "Xavier Poinsard"
Дата:
Сообщение: Re: Error while trying to connect to postgresql