Re: Java access pgsql sample - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: Java access pgsql sample
Date
Msg-id 1027624642.30770.61.camel@inspiron.cramers
Whole thread Raw
In response to Java access pgsql sample  ("Ribamar FS" <ribafs@myrealbox.com>)
List pgsql-jdbc
Where did you put the postgres jar, and where is it referenced in the
classpath?

Dave
On Thu, 2002-07-25 at 15:10, Ribamar FS wrote:
> Hi!
>
> Help me with this sample. It don't work:
>
> Linux Conectiva
> Postgresql 7.2.1
> pgjdbc2.jar
>
> /etc/profile
> JAVA_HOME="/usr/java/jsdk"
> J2EE_HOME="/usr/java/j2ee"
> CLASSPATH=".:$JAVA_HOME/lib:$J2EE_HOME/lib:/usr/java/jsdk/corejava/corejava.zip"
> J2EE_CLASSPATH=$CLASSPATH
> PATH="$PATH:$JAVA_HOME/bin:$J2EE_HOME/bin"
> export JAVA_HOME J2EE_HOME CLASSPATH J2EE_CLASSPATH
>
>
> import java.sql.*;
> public class SQLStatement  {
>     public static void main(String args[]) {
>         String url = "jdbc:postgresql:javatest";
>         Connection con;
>         String query = "select col1 from test";
>         Statement stmt;
>         try {
>             Class.forName("org.postgresql.Driver");
>         } catch(java.lang.ClassNotFoundException e) {
>             System.err.print("ClassNotFoundException: ");
>             System.err.println(e.getMessage());
>         }
>         try {
>             con = DriverManager.getConnection(url,"postgres", "postgres");
>
>             stmt = con.createStatement();
>
>             ResultSet rs = stmt.executeQuery(query);
>             ResultSetMetaData rsmd = rs.getMetaData();
>             int numberOfColumns = rsmd.getColumnCount();
>             int rowCount = 1;
>             while (rs.next()) {
>                 System.out.println("Linha " + rowCount + ":  ");
>                 for (int i = 1; i <= numberOfColumns; i++) {
>                     System.out.print("   Coluna " + i + ":  ");
>                     System.out.println(rs.getString(i));
>                 }
>                 System.out.println("");
>                 rowCount++;
>             }
>             stmt.close();
>             con.close();
>
>         } catch(SQLException ex) {
>             System.err.print("SQLException: ");
>             System.err.println(ex.getMessage());
>         }
>     }
> }
>
>
> Errors:
> ClassNotFoundException: org/postgresql/Driver
> SQLException: driver not found: jdbc:postgresql:javatest
>
>
> Thank you for attention. Sorry ny english (brasilian).
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
>




pgsql-jdbc by date:

Previous
From: "Ribamar FS"
Date:
Subject: Java access pgsql sample
Next
From: Yuva Chandolu
Date:
Subject: Re: Java access pgsql sample