Re: SQL Error JDBC

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Administration <admin(at)isorintrade(dot)ca>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: SQL Error JDBC
Date: 1999-02-24 09:14:40
Message-ID: Pine.LNX.4.04.9902240913220.3146-100000@maidast.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Tue, 23 Feb 1999, Administration wrote:

> I have postgresql running in linux on a network, and I have a sample
> program in windows. When I run the following
>
> java -classpath .;c:\jdk1.2\lib\postgresql.jar test
>
> I get this error
>
> sqlexception: no suitable driver
>
> Any ideas??

You still need to load the driver, using something like:

try {
Class.forName("postgresql.Driver");
} catch(Exception ex) {
ex.printStackTrace();
System.exit(1);
}

> Henry
>
> Here's my code(i'm pasting it because it's short:)
> ---------------------------------------------------------------------------------------
>
> import java.sql.*;
>
>
> public class test {
> public static void main(String args[]) {
> String url = "jdbc:postgres95://isorintrade.ca:5432/ra";
> Connection con;
> String createString;
> createString = "create table COFFEES " +
> "(COF_NAME VARCHAR(32), " +
> "SUP_ID INTEGER, " +
> "PRICE FLOAT, " +
> "SALES INTEGER, " +
> "TOTAL INTEGER)";
> Statement stmt;
>
> try {
> Class.forName("postgresql.Driver");
> } catch(java.lang.ClassNotFoundException e) {
> System.err.print("ClassNotFoundException: ");
> System.err.println(e.getMessage());
> }
>
> try {
> con = DriverManager.getConnection(url, "postgres",
> "feb_1b42");
> stmt = con.createStatement();
> stmt.executeUpdate(createString);
> stmt.close();
> con.close();
>
> } catch(SQLException ex) {
> System.err.println("SQLException: " + ex.getMessage());
> }
> }
> }
>
>

--
Peter T Mount peter(at)retep(dot)org(dot)uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Valerio Santinelli 1999-02-24 10:45:13 xmin field in a newly created table.
Previous Message Michael Davis 1999-02-24 06:22:31 Access 97 and Postgress