X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 0AD6F11F65DB for ; Thu, 27 Apr 2006 10:26:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 14232-09 for ; Thu, 27 Apr 2006 10:25:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id 3865311F65D9 for ; Thu, 27 Apr 2006 10:25:42 -0300 (ADT) Received: (qmail 30937 invoked from network); 27 Apr 2006 13:25:42 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 27 Apr 2006 13:25:42 -0000 In-Reply-To: <4450B6E2.3020503@timmy.dk> References: <4450B6E2.3020503@timmy.dk> Mime-Version: 1.0 (Apple Message framework v749.3) Content-Type: multipart/alternative; boundary=Apple-Mail-15-333417153 Message-Id: Cc: pgsql-jdbc@postgresql.org From: Dave Cramer Subject: Re: java.sql.SQLException: No suitable driver Date: Thu, 27 Apr 2006 09:25:41 -0400 To: Mads N. Vestergaard X-Mailer: Apple Mail (2.749.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/170 X-Sequence-Number: 15104 --Apple-Mail-15-333417153 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed 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 driver > at 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.NullPointerException > at 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.jar > Java version: > hostname:~$ java -version > java 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. --Apple-Mail-15-333417153 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 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 =
driver
=A0 =A0 =A0 =A0 at =
java.sql.DriverManager.getConnection(Unknown Source)
=A0 =A0 =
=A0 =A0 at java.sql.DriverManager.getConnection(Unknown Source)
=
=A0 =A0 =A0 =A0 at Database.(Database.java:20)
=A0 =
=A0 =A0 =A0 at Gateway.main(Gateway.java:19)
Exception in =
thread "main" java.lang.NullPointerException
=A0 =A0 =A0 =A0 =
at Database.SQLget(Database.java:71)
=A0 =A0 =A0 =A0 at =
Gateway.main(Gateway.java:33)
My connect code is:
=
try {
=A0 =A0 =
Class.forName("org.postgresql.Driver");
=A0 =A0 =A0 }catch =
(ClassNotFoundException e){
=A0 =A0 =A0 }
=A0 =A0 =
=A0 try {
=A0 =A0 =A0 =A0 db =3D =
DriverManager.getConnection("jdbc:postgresql://hostname/" + =
dbName,"bruger","kode");
=A0 =A0 =A0 } catch (SQLException e) =
{
=A0 =A0 =A0 =A0 e.printStackTrace();
=A0 =A0 =A0 =
}
On my system I have putted the jdbc driver for postgres =
into the classpath:
hostname:~$ echo $CLASSPATH
=
/usr/share/java/pg74.216.jdbc3.jar
Java version:
=
hostname:~$ java -version
java 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.
=

= --Apple-Mail-15-333417153--