Problem with JDBC: no suitable driver

Поиск
Список
Период
Сортировка
От Konstantinos Spyropoulos
Тема Problem with JDBC: no suitable driver
Дата
Msg-id 002101c21d5e$ea187d40$e1df6693@s
обсуждение исходный текст
Список pgsql-jdbc
Hello!
I'm having a problem with the JDBC driver: I am getting the "no suitable driver" exception
when I try to log on to the database through a simple java program.
 
I have postgresql 7.2.1 running in Win98, with Cygwin. The database was downloaded
and installed through the Cygwin setup. The JDBC driver I use is the one that comes with
Cygwin. Java is installed in windows in d:Programming/j2sdk1.4.0
The postmaster is initiated with the parameter -i and in case it matters I have the ipc-daemon running.
 
My variables are:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:.:/home/inigo:/cygdrive/c/WINDOWS:/cygdrive/c/W
INDOWS/COMMAND:/cygdrive/d/PROGRAMMING/J2SDK1.4.0/BIN
$ echo $CLASSPATH
/usr/share/postgresql/java/postgresql.jar:/cygdrive/d/PROGRAMMING/J2SDK1.4.0/LIB
 
When I try to run the program below, I get the exception:
$ java test
org.postgresql.Driver
While connecting: No suitable driver
 
I even tried to run the program, removing the Class.forName line, giving the JDBC drivers
in command line, but the result was the same.
Sorry for the big mail, but I'm new to Postgres, JDBC and Cygwin, and at a loss.
 
Thank you all.
 
Here is the code of my program. (That program used to work in Postgres when I had Linux.)
 
import java.sql.*;
 
public class test {
  public static void main(String args[]) {
    try {
      Class.forName("org.postgresql.Driver");
    } catch (ClassNotFoundException e) {
      System.out.println(e.getMessage());
    }
    try {
      Connection db = DriverManager.getConnection("jdbc:postgresql://localhost:5432/inigo", "inigo", null);
    } catch(SQLException e) {
      System.out.println("while connecting: " + e.getMessage());
    }
  }
}

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

Предыдущее
От: Daryl Beattie
Дата:
Сообщение: Re: JDBC + PL/pgSQL ?
Следующее
От: Robert Treat
Дата:
Сообщение: DBVisualizer Null Pointer Exception