Обсуждение: Help!Can't connect Postgresql JDBC driver

Поиск
Список
Период
Сортировка

Help!Can't connect Postgresql JDBC driver

От
Cheung Yip San
Дата:
Could anyone tell me how can I write the applet to connect the
PostgreSQL?


I have installed the Postgresql 7.0.3 RPM on RedHat 6.2 server and try
to write the applet program to access the database. But the following
error make me confuse :

java.lang.ClassNotFoundException: java.io.FileNotFoundException:
http://itdpc27b/~earnest/project/postgresql/Driver.class

I have installed the PSQL 7.0.3 JDBC RPM on the server, I can't see the
"postgresql.jar" but "jdbc7.0.1-1.jar", "jdbc7.0.1-2.jar".


Also, I have tried to run this program from my own desktop PC and on the
linux server locally, but both are encountered the same error.


The following is my program (MyDB.java)

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.sql.*;

public class MyDB extends Applet{
Connection db;

public void init(){
 try {
  Class.forName("postgresql.Driver");
      String urlStr="jdbc:postgresql://itdpc27b:5432/testdb";
      db=DriverManager.getConnection(urlStr, "earnest", "password");
 } catch (ClassNotFoundException e) {
  e.printStackTrace();
    return;
   }
   catch (SQLException es) {
  System.out.println("SQL Error");
    return;
      }


  try {
   Statement st = db.createStatement();
  ResultSet rs = st.executeQuery("select * from customer");
  while(rs.next()) {
      System.out.print("Column 1 returned ");
      System.out.println(rs.getString(1));
  }
    rs.close();
    st.close();
 } catch (SQLException es) {
  System.out.println("SQL Error");
    return;
      }
}



Re: Help!Can't connect Postgresql JDBC driver

От
brlspam@sperience.com
Дата:
One problem: use "org.postgresql.Driver", not "postgresql.Driver".

I don't write applets.  Can they have jars in the classpath or do you
have to extract all the .class files?

--
Bruce R. Lewis                http://brl.sourceforge.net/


Re: Help!Can't connect Postgresql JDBC driver

От
"George Johnson"
Дата:
I'm not sure if this helps, but for some reason,
Class.forName("postgresql.Driver") is listed but probably should be
Class.forName("org.postgresql.Driver") ... the driver is actually beneath
the org directory.  I'm not familar with linux variants of the PostgreSQL
stuff.  Sometimes when in doubt, unjar (jar -xvf) the jar files and look at
what's inside.  That often times points to problems.  Also, always remember
to include jar files in your classpath.

Is there a postgresql.jdbc or postgresql.java mailing list?  This probably
belongs there ...

George Johnson


----- Original Message -----
From: "Cheung Yip San" <monitorc@netvigator.com>
To: <pgsql-general@postgresql.org>
Sent: Wednesday, December 13, 2000 7:48 AM
Subject: Help!Can't connect Postgresql JDBC driver


> Could anyone tell me how can I write the applet to connect the
> PostgreSQL?
>
>
> I have installed the Postgresql 7.0.3 RPM on RedHat 6.2 server and try
> to write the applet program to access the database. But the following
> error make me confuse :
>
> java.lang.ClassNotFoundException: java.io.FileNotFoundException:
> http://itdpc27b/~earnest/project/postgresql/Driver.class
>
> I have installed the PSQL 7.0.3 JDBC RPM on the server, I can't see the
> "postgresql.jar" but "jdbc7.0.1-1.jar", "jdbc7.0.1-2.jar".
>
>
> Also, I have tried to run this program from my own desktop PC and on the
> linux server locally, but both are encountered the same error.
>
>
> The following is my program (MyDB.java)
>
> import java.awt.*;
> import java.awt.event.*;
> import java.applet.*;
> import java.sql.*;
>
> public class MyDB extends Applet{
> Connection db;
>
> public void init(){
>  try {
>   Class.forName("postgresql.Driver");
>       String urlStr="jdbc:postgresql://itdpc27b:5432/testdb";
>       db=DriverManager.getConnection(urlStr, "earnest", "password");
>  } catch (ClassNotFoundException e) {
>   e.printStackTrace();
>     return;
>    }
>    catch (SQLException es) {
>   System.out.println("SQL Error");
>     return;
>       }
>
>
>   try {
>    Statement st = db.createStatement();
>   ResultSet rs = st.executeQuery("select * from customer");
>   while(rs.next()) {
>       System.out.print("Column 1 returned ");
>       System.out.println(rs.getString(1));
>   }
>     rs.close();
>     st.close();
>  } catch (SQLException es) {
>   System.out.println("SQL Error");
>     return;
>       }
> }
>
>
>


Re: Re: Help!Can't connect Postgresql JDBC driver

От
Joseph Shraibman
Дата:
George Johnson wrote:
>
> I'm not sure if this helps, but for some reason,
> Class.forName("postgresql.Driver") is listed but probably should be
> Class.forName("org.postgresql.Driver") ... the driver is actually beneath
> the org directory.  I'm not familar with linux variants of the PostgreSQL
> stuff.  Sometimes when in doubt, unjar (jar -xvf) the jar files and look at
> what's inside.  That often times points to problems.  Also, always remember
> to include jar files in your classpath.
>
> Is there a postgresql.jdbc or postgresql.java mailing list?  This probably
> belongs there ...
>

The interfaces list.


--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com

Re: Help!Can't connect Postgresql JDBC driver

От
Greg@10happythings.com (Greg Speegle)
Дата:
You can have jars with an applet by using the ARCHIVE field in the
applet tag.

Something like . . .

<APPLET CODE = "JDBC.class" ARCHIVE = "jdbc7_0-1_2.jar" WIDTH = 400 HEIGHT =
400>

Good luck,

Greg Speegle

In article <nm9puiw9hem.fsf@kindness.mit.edu>, brlspam@sperience.com says...
>
>One problem: use "org.postgresql.Driver", not "postgresql.Driver".
>
>I don't write applets.  Can they have jars in the classpath or do you
>have to extract all the .class files?
>
>--
>Bruce R. Lewis                          http://brl.sourceforge.net/
>