JDBC SQL command problems

From: Jeffrey Napolitano <jnapoli(at)setech(dot)com>
To: General Questions for PostgreSQL <pgsql-general(at)postgreSQL(dot)org>
Subject: JDBC SQL command problems
Date: 1998-07-02 16:51:01
Message-ID: 359BBA75.7FF712ED@setech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've compiled and installed the JDBC driver for Postgresql - Now I'm
attempting to make the connection work, and pass a CREATE command to
postgres.

My database name is "bugs", the user connecting is "java", and its
running on my local machine on port 5432. I am consistently getting a
"The SQL Exception was thrown" ... after changing things around, I still
get the same result. I've been reading "JDBC Database Access with Java"
by Hamilton, Cattell, and Fisher, and their example doesn't work.

Help?

----------------------------------
public class JDBC_Connection {
public static void main(String[] args) {
String url =
"jdbc:postgresql?user=java://localhost:5432/bugs";
Connection con;
String createString;
createString = "create table STUFF " + "(NAME
varchar(30), " + "YOUR_MOM int)";
Statement stmt;

try {
Class.forName("postgresql.Driver");
}
catch(ClassNotFoundException except) {
System.out.println("ClassNotFound: didn't
work");
}

try {
con = DriverManager.getConnection(url);
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();

catch(SQLException sqlexcept) {
System.out.println("The SQL Exception was
thrown");
}
} //End of main in JDBC_Connection class
} //End of JDBC_Connection class bracket

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Olin Oden 1998-07-02 18:23:30 Re: [GENERAL] JDBC SQL command problems
Previous Message Rob den Boer 1998-07-02 10:24:15 RE: [GENERAL] vacuuming