Skip site navigation (1) Skip section navigation (2)

Re: "No Suitable Driver"

From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "'Guy McArthur'" <guym(at)guymcarthur(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: "No Suitable Driver"
Date: 2001-10-25 01:11:18
Message-ID: 029a01c15cf1$f3d54a80$8201a8c0@inspiron (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
You need to load the driver first and then get the connection, also the
url for the connection s/b


Assuming your database name is test

So your code needs to execute 

And then
Connection db =


-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Guy McArthur
Sent: October 24, 2001 7:13 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] "No Suitable Driver"

Hi, I'm trying to get a small test program going. I have built
PostgreSQL 7.1.3 on RedHat 6.2 with --java, installed and created
databases, verified with psql. The postgresql.jar is on my classpath.

My pg_hba.conf has:
local        all                                           password
host         all     password

Here is my code:

import java.sql.*;

public class PostgresTest {
   public static void main(String[] args) {
     try {
      Connection db =
// I've also tried all the permutations of getConnection() and urls. //
db, user, and password names have been changed to protect the innocent
// I've also tried Class.forName("org.postgresql.Driver") and //
Class.forName("org.postgresql.Driver").newInstance() instead of the arg.
     } catch(Throwable t) {

Running it with:

java -Djdbc.drivers=org.postgresql.Driver PostgresTest
where the db has been started by user postgres with:
/usr/local/pgsql/bin/postmaster -i -D /data/pgsql >/data/pgsql/pgsql.log
2>&1 &

And the error is:

java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getConnection(
        at java.sql.DriverManager.getConnection(
        at PostgresTest.main(

What is wrong?

Guy McArthur * email{guym(at)arizona(dot)edu} http{}

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

In response to


pgsql-jdbc by date

Next:From: Mark LillywhiteDate: 2001-10-25 01:18:57
Subject: Re: [PATCHES] DatabaseMetadata patch
Previous:From: PaulDate: 2001-10-25 00:46:59
Subject: Code Fixes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group