[Q] Can't get simple JDBC connection to work: "no suitable driver"

From: Amandeep Jawa <deep(at)worker-bee(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: [Q] Can't get simple JDBC connection to work: "no suitable driver"
Date: 2001-10-11 23:28:06
Message-ID: B7EB7915.17BA%deep@worker-bee.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

(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(at)worker-bee(dot)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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Amandeep Jawa 2001-10-12 02:49:59 Re: [Q] Can't get simple JDBC connection to work: "no suit
Previous Message Barry Lind 2001-10-11 20:21:26 Re: date problem with postgres JDBC 7.1 driver