pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <Dave@micro-automation.net>
To: 'Guy McArthur' <guym@guymcarthur.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: "No Suitable Driver"
Date: Wed, 24 Oct 2001 21:11:18 -0400
Message-ID: <029a01c15cf1$f3d54a80$8201a8c0@inspiron> (raw)
In-Reply-To: <Pine.LNX.4.33.0110241553270.10396-100000@astronomica.as.arizona.edu>

You need to load the driver first and then get the connection, also the
url for the connection s/b

jdbc:postgresql://hostname/test&user=test&password=test"

Assuming your database name is test


So your code needs to execute 
Class.forName("org.postgresql.Driver")

And then
Connection db =
DriverManager.getConnection("jdbc:postgresql://hostname/test"test",test"
);

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Guy McArthur
Sent: October 24, 2001 7:13 PM
To: pgsql-jdbc@postgresql.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         127.0.0.1     255.255.255.255     password

Here is my code:

import java.sql.*;

public class PostgresTest {
   public static void main(String[] args) {
     try {
      Connection db =
DriverManager.getConnection("jdbc.postgresql:test&user=test&password=tes
t");
// 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.
      db.close();
     } catch(Throwable t) {
         t.printStackTrace(System.out);
     }
   }
}

--
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(DriverManager.java:537)
        at java.sql.DriverManager.getConnection(DriverManager.java:199)
        at PostgresTest.main(PostgresTest.java:6)


What is wrong?

--
Guy McArthur * email{guym@arizona.edu} http{guymcarthur.com}





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

http://archives.postgresql.org





view thread (30+ messages)  latest in thread

Message-ID: <029a01c15cf1$f3d54a80$8201a8c0@inspiron>
Permalink:  ../029a01c15cf1$f3d54a80$8201a8c0@inspiron/
Also on:    postgresql.org/message-id/029a01c15cf1$f3d54a80$8201a8c0@inspiron

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Dave@micro-automation.net, guym@guymcarthur.com
  Subject: Re: "No Suitable Driver"
  In-Reply-To: <029a01c15cf1$f3d54a80$8201a8c0@inspiron>
  References: <Pine.LNX.4.33.0110241553270.10396-100000@astronomica.as.arizona.edu> <029a01c15cf1$f3d54a80$8201a8c0@inspiron>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox