Re: java.sql.SQLException: No suitable driver
От | Dave Cramer |
---|---|
Тема | Re: java.sql.SQLException: No suitable driver |
Дата | |
Msg-id | AEE99EF3-AC28-488F-AAC7-DE9B87FE1A03@fastcrypt.com обсуждение исходный текст |
Ответ на | java.sql.SQLException: No suitable driver ("Mads N. Vestergaard" <mnv@timmy.dk>) |
Ответы |
Re: java.sql.SQLException: No suitable driver
|
Список | pgsql-jdbc |
5 will get you 10 that your class path isn't setup correctly. Try adding ex.printStackTrace() to the catch handler for Class.forName
Dave
On 27-Apr-06, at 8:19 AM, Mads N. Vestergaard wrote:
Hi Everybody, when I try to run my program, I get the following error message:java.sql.SQLException: No suitable driverat java.sql.DriverManager.getConnection(Unknown Source)at java.sql.DriverManager.getConnection(Unknown Source)at Database.(Database.java:20)at Gateway.main(Gateway.java:19)Exception in thread "main" java.lang.NullPointerExceptionat Database.SQLget(Database.java:71)at Gateway.main(Gateway.java:33)My connect code is:try {Class.forName("org.postgresql.Driver");}catch (ClassNotFoundException e){}try {db = DriverManager.getConnection("jdbc:postgresql://hostname/" + dbName,"bruger","kode");} catch (SQLException e) {e.printStackTrace();}On my system I have putted the jdbc driver for postgres into the classpath:hostname:~$ echo $CLASSPATH/usr/share/java/pg74.216.jdbc3.jarJava version:hostname:~$ java -versionjava version "1.5.0_06"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)As far as I know it should work since, it is correct in the classpath. I have also tried with other postgres jdbc drivers. In my IDE(Eclipse), it works fine, but on my production server it gives the error.I've also tried to run the program with the -classpath flag, with the same result.Have I simply forgotten something, or is there something seriously wrong?Thanks in advance.
В списке pgsql-jdbc по дате отправления: