From: | Barry Lind <blind(at)xythos(dot)com> |
---|---|
To: | Joseph Thomas <greywolf921(at)hotmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: JDBC in Red hat 9 |
Date: | 2003-05-29 04:58:02 |
Message-ID: | 3ED5935A.1070607@xythos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Joseph,
Two things wrong that I can see:
1) The driver class is now org.postgresql.Driver (not postgresql.Driver)
2) You only include one of the jar files in the classpath (the one that
corresponds to the version of java/jdbc you are running: jdbc1 = jdk1.1,
jdbc2= jdk1.2 and 1.3, jdbc3= jdk1.4
thanks,
--Barry
Joseph Thomas wrote:
> Ok I am new to Linux, so please bear with me. I am running Red Hat 9
> that comes with PostgreSQL7.3.2-3.
>
> I have created a "test" database and am trying to access it using a java
> program through jdbc.
> I am recieving and error: "Exception! java.lang.ClassNotFoundException:
> postgresql.Driver"
>
> I have my CLASSPATH set to point to pg73b1jdbc1.jar, pg73b1jdbc2.jar and
> pg73b1jdbc3.jar.
>
> I am reading a HOW TO for jdbc and PostgreSQL From
> http://tldp.org/HOWTO/Enterprise-Java-for-Linux-HOWTO-6.html but this is
> for version 6.5, do I need to do anything else?
>
> here is my java code:
> import java.sql.*;
>
> class PostgreSQLTest {
> public static void main (String[] args) {
> try {
> Driver driver = (Driver)
> Class.forName("postgresql.Driver").newInstance();
> DriverManager.registerDriver(driver);
>
> String url = "jdbc:postgresql:javatest";
> Connection con = DriverManager.getConnection(url, "postgres", "");
> Statement stm = con.createStatement();
>
> stm.setQueryTimeout(10);
> ResultSet rs = stm.executeQuery("select col1 from test");
>
> rs.next();
>
> System.out.println(rs.getString(1));
>
> } catch (SQLExcept ion e) {
>
> System.out.println("Exception!");
> System.out.println(e.toString());
> }
> }
>
> ------------------------------------------------------------------------
> Tired of spam? Get advanced junk mail protection
> <http://g.msn.com/8HMLENUS/2734??PS=> with MSN 8.
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2003-05-29 05:25:21 | Re: Newbie postgres/JDBC question. |
Previous Message | Barry Lind | 2003-05-29 04:53:32 | Re: [PATCHES] JDBC: Wrong type |