X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 668115339A for ; Mon, 4 Apr 2005 12:57:00 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78782-07 for ; Mon, 4 Apr 2005 11:56:54 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 300A452A5C for ; Mon, 4 Apr 2005 12:56:53 +0100 (BST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 6A14430952; Mon, 4 Apr 2005 13:56:42 +0200 (MET DST) From: "Nico" X-Newsgroups: pgsql.interfaces.jdbc Subject: Re: Another java connect problem Date: Mon, 4 Apr 2005 13:56:43 +0200 Organization: Hub.Org Networking Services Lines: 68 Message-ID: References: <425121BB.8020603@statkart.no> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Response To: pgsql-jdbc@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=3.359 tagged_above=0 required=5 tests=AWL, FORGED_YAHOO_RCVD, PRIORITY_NO_NAME X-Spam-Level: *** X-Archive-Number: 200504/12 X-Sequence-Number: 12619 Why do you use 'Class.forName("org.postgresql.Driver").newInstance();'? Just use 'Class.forName("org.postgresql.Driver");' Oh, by the way, it's probably something you forgot in your e-mail, but DriverManager.getConnection(url, "user", "password); is not correct, it has to be: DriverManager.getConnection(url, "user", "password"); That's the way it works for me... Nico. ""Espen Isaksen"" schreef in bericht news:425121BB.8020603@statkart.no... > Hi! > > I have studied all the different questions where people have trouble > connecting to PostgreSQL through Java, but it doesn't help me > much. This is a program I first compiled on a Mac and I have no > problems at all there. Now I am on Fedora Linux. > > First my code: > Connection dbcon; > java.sql.Connection conn; > String url = "jdbc:postgresql://localhost:5432/espen"; > try { > Class.forName("org.postgresql.Driver").newInstance(); > } > catch( ClassNotFoundException cnfex ) { > System.out.println("Class not found!"); > } //end catch > conn = DriverManager.getConnection(url, "user", "password); > Statement stmt = conn.createStatement(); > s = conn.createStatement(); > > > I compile by using this command: > javac @files -classpath postgis.jar:postgresql.jar (where files include a > list of all the .java files) > > No problems compiling. > > I try to run by: > java road_generalization -verbose -classpath postgis.jar:postgresql.jar > > Then I get the usual error message: > > Unable to connect > java.sql.SQLException: No suitable driver > at java.sql.DriverManager.getConnection(Unknown Source) > at java.sql.DriverManager.getConnection(Unknown Source) > at DataUthenter.connectPostgres(DataUthenter.java:67) > at DataUthenter.(DataUthenter.java:31) > at road_generalization.(road_generalization.java:99) > at road_generalization.main(road_generalization.java:383) > > I have tried to change the code in a lot of different ways, but it does > not > seem to help much. Can anybody give me some insight in why this > doesn't work. Is my "run command" not correct? > > Espen Isaksen > http://www.espenisaksen.com > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings >