Thread: cannot find org.postgres.Driver

cannot find org.postgres.Driver

From
Felipe
Date:
Hi everybody
 
I'm trying to write an applet to acces postgres but when I load the applet in a web browser doesn't seems to work. In the JVM console I obtain an error that says something like this
 
Cannot find "/home/applets/org/postgresql/Driver"
 
the code I use to load the postgres driver is as follows
 
Class.forName("org.postgresql.Driver");
Connection db = DriverManager.getConnection("jdbc:postgresql:arl",user,password);
 
where arl is the database name
 
for you anwser thanks



Do You Yahoo!?
Yahoo! Net: La mejor conexión a internet y 25MB extra a tu correo por $100 al mes.

Re: cannot find org.postgres.Driver

From
Dave Cramer
Date:
Felipe,

from the http://jdbc.postgresql.org/doc.htm site

So our url? It's one of the following:

        jdbc:postgresql:database
        jdbc:postgresql://host/database
        jdbc:postgresql://host:port/database

where database is the database to connect to, host the server to connect
to, and port the port number.

If left out, host defaults to localhost (not 127.0.0.1 see applets!) and
port to 5432 (configurable at build time).

Dave

On Tue, 2004-05-25 at 18:44, Felipe wrote:
> Hi everybody
>
> I'm trying to write an applet to acces postgres but when I load the
> applet in a web browser doesn't seems to work. In the JVM console I
> obtain an error that says something like this
>
> Cannot find "/home/applets/org/postgresql/Driver"
>
> the code I use to load the postgres driver is as follows
>
> Class.forName("org.postgresql.Driver");
> Connection db =
> DriverManager.getConnection("jdbc:postgresql:arl",user,password);
>
> where arl is the database name
>
> for you anwser thanks
>
>
>
> ______________________________________________________________________
> Do You Yahoo!?
> Yahoo! Net: La mejor conexión a internet y 25MB extra a tu correo por
> $100 al mes.
> !DSPAM:40b3cd80232576939882854!
--
Dave Cramer
519 939 0336
ICQ # 14675561


Re: cannot find org.postgres.Driver

From
Ulrich Meis
Date:
Felipe wrote:

> Cannot find "/home/applets/org/postgresql/Driver"
>


Did you extract the jdbc classes or are you using the postgresql.jar file?
If you use the jar, did you mention it in the archive property of your
applet/object/embed tag?

Your html page and your directory structure would help.

Greetings,

Uli



Re: cannot find org.postgres.Driver

From
Felipe
Date:
I'm using the file pg73jdbc3.jar which is included in my classpath
 
well, my directory structure is:
 
/home/Documents/dbConnection/classes/dbconnection
here are all classes
 
and html file is in
/home/Documents/dbConnection/classes/
 
my source code is as follows
 
package dbconnection;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.sql.*;
 
public class Conectame1 extends JApplet {
 
//Construct the applet
public Conectame() {
}
 
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
 
//Component initialization
private void jbInit() throws Exception, ClassNotFoundException, SQLException{
conexion esta = new conexion();
jLabel1.setText("database name: "+esta.db.getDatabaseProductName());
this.setSize(new Dimension(400,300));
this.getContentPane().add(jLabel1, BorderLayout.CENTER);
}
}
 
class conexion {
Connection db;
DatabaseMetaData dbmd;
public conexion() throws ClassNotFoundException, SQLException
{
Class.forName("org.postgresql.Driver");
db = DriverManager.getConnection("jdbc:postgresql:arl","pipo","jamara16");
dbmd = db.getMetaData();
}
public static void main(String[] args) throws SQLException, ClassNotFoundException
{
conexion conexion1 = new conexion();
}
}
 
my html code is as follows
html>
head>
title>
HTML Test Page
/title>
/head>
body>
dbconnection.Conectame will appear below in a Java enabled browser.<br>
applet
codebase = "."
code = "dbconnection.Conectame.class"
name = "TestApplet"
width = "400"
height = "300"
hspace = "0"
vspace = "0"
align = "middle"
>
/applet>
/body>
/html>
(I erased the '<' for my mail manager)
thanks for your answer
 



Do You Yahoo!?
Yahoo! Net: La mejor conexión a internet y 25MB extra a tu correo por $100 al mes.

Re: cannot find org.postgres.Driver

From
Ulrich Meis
Date:
Felipe wrote:

> I'm using the file pg73jdbc3.jar which is included in my classpath
>


And here's the problem. Your browser uses the Java Plugin and that has a
different classpath. You can set it on your machine, but you can't set
it on everyone's machine who's going to visit your page.
You need to include the jar file in your applet tag. I am not sure if it
is possible with a plain <applet> tag, but you can try to add
codebase="pg73jdbc3.jar".
That might fail, but with JDK 1.2 applets you shouldn't use that tag
anyway. Unfortunately it depends on the browser if you need to use an
<object> or an <embed> tag, but the whole matter is best discussed here:
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/contents.html
where you can find a solution for both major browser families out there.

Greetings,

Uli