Re: [Q] Can't get simple JDBC connection to work: "no suit - Mailing list pgsql-jdbc
From | Joe Shevland |
---|---|
Subject | Re: [Q] Can't get simple JDBC connection to work: "no suit |
Date | |
Msg-id | C56487636E5CD4119B1E00D0B789098A011C5CBC@mel-exch1.eclipsegroup.com Whole thread Raw |
List | pgsql-jdbc |
jdbc:postgresql:... ^^ Cheers, Joe > -----Original Message----- > From: pgsql-jdbc-owner@postgresql.org > [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Amandeep Jawa > Sent: Friday, 12 October 2001 9:28 AM > To: pgsql-jdbc@postgresql.org > Subject: [JDBC] [Q] Can't get simple JDBC connection to work: "no > suitable driver" > > > (PLEASE email any replies to me directy as well as posting) > > Hey folks - > > I hope someone can help. I'm trying to get a VERY simple > JDBC connection > working with the JDBC drivers but I am consistently getting a > "no suitable > driver" error. > > I am trying a very very simple test program to access my > little PostgreSQL > database & I am using the jdbc driver: jdbc7.1-1.2.jar > (binary downloaded > from www.postgresql.org). > > The error I'm getting is: > > Exception in thread "main" java.sql.SQLException: No suitable driver > at java.sql.DriverManager.getConnection(DriverManager.java:537) > at java.sql.DriverManager.getConnection(DriverManager.java:177) > at testpost.main(testpost.java:14) > > > The command I'm running is: > > java -cp /usr/share/pgsql/jdbc7.1-1.2.jar testpost > > The code is: > > // testpost.java > > import java.sql.*; > > public class testpost > { > > public static void main(String argv[]) throws Exception > { > System.out.println("Beginning Postgres Test"); > Class.forName("org.postgresql.Driver"); > > System.out.println("Loaded Driver."); > Connection conn = DriverManager.getConnection( > "jdbc:postgres:test", > "postgres", > "notreallymypassword" > ); > > System.out.println("Got connection."); > /* COMMENTED OUT UNTIL I KNOW THE REST WORKS > Statement stmt = conn.createStatement(); > ResultSet rset = stmt.executeQuery("SELECT now();"); > > System.out.println("Ran now query..\nResults:\n"); > while (rset.next()) > { > System.out.println(rset.getString(1)); > } > > rset.close(); > stmt.close(); > */ > conn.close(); > > System.out.println("Closed connection & Ended Test"); > > } > > } > > > > The ouput I get is: > > Beginning Postgres Test > Loaded Driver. > Exception in thread "main" java.sql.SQLException: No suitable driver > at java.sql.DriverManager.getConnection(DriverManager.java:537) > at java.sql.DriverManager.getConnection(DriverManager.java:177) > at testpost.main(testpost.java:14) > > I'm using postgres 7.1.3 installed from RPMs (from Postgres) > on Red Hat > Linux 7.1 with Sun's jdk 1.3.1 also installed from RPMs (from Sun). > > I have a "postgres" user on my machine. I have made the > database "test". > Not that I think these things matter because it doesn't seem > to be getting > that far. I am starting the postgres server from the root > user with the > following command: > /etc/rc.d/init.d/postgresql start > & it seems to be starting fine. I have also turned on tcp-ip > connections in > the conf file. > > Couple of other facts: > - One thing I notice is that the documentation all refers to a > "postgressql.jar" which I can't find. I can find the > "jdbc7.1-1.2.jar" > which is what I'm using. > > - One other thing I have tried is to rebuild the drivers from > scratch - this > does give me a postgresql.jar - but the error is the same. > > - I have also noticed that the jar files are not always the same size: > jdbc7.1-1.2.jar from postgresql-jdbc-7.1.3-1PGDG.i386.rpm : > 88169 bytes > jdbc7.1-1.2.jar from jdbc.postgresql.org : 93011 bytes > But the error is the same :-) > > > Any help would be greatly appreciated - and please email replies to me > directly as well as the list. > > THANKS in advance. > 'deep > > > ---------------------------------- > Amandeep Jawa > Worker Bee Software > ---------------------------------- > deep@worker-bee.com > 225A Dolores St. > San Francisco, CA 94103-2202 > > Home: 415 255 6257 (ALL MALP) > > professional: http://www.worker-bee.com > personal: http://www.deeptrouble.com > political: http://www.sflcv.org > > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >
pgsql-jdbc by date: