How can I view a JDBC application created on an Applet in a Browser

T

tsynth

Hello all and thanks to all that try to help me.

Here is my case. I am working on Project for a Java programming class.
I have created some JDBC applications that query a MySQL database and
they work perfectly when i run them through appletviewer as JApplets,
or as JFrame. The only problem is that when i attempt to run them from
the browser I get an error message something like "Database driver
cannot be found" . Im pretty sure that this is a security issue with
the browser not allowing the applet access the database driver
directly. My project is a website that uses MySQL as a backend, so i
really need to run my applications on a browser.

So my question is how can i run my applications on a Browser? Do I
have to install a web server such as apache?
 
A

Andrew Thompson

Hello all and thanks to all that try to help me.

Here is my case. I am working on Project for a Java programming class.
I have created some JDBC applications that query a MySQL database and
they work perfectly when i run them through appletviewer as JApplets,

Applets are a lot more difficult to debug and deploy
than applications.
or as JFrame. The only problem is that when i attempt to run them from
the browser ...

URL? Where can we visit this problem applet?
..I get an error message something like "Database driver
cannot be found" .

Something like? Please don't waste your time and our
bandwidth with errors that are 'something like' what is
happening. Always be very specific, and then state
along the lines of 'the error *is*..'.
...Im pretty sure that this is a security issue with
the browser not allowing the applet access the database driver
directly.

Most likely. What is the applet element in the web page of
the URL you had not mentioned? What errors are reported
in the Java console?
..My project is a website that uses MySQL as a backend, so i
really need to run my applications on a browser.

That is not true. An application, or a web started application or
applet, can also access the information or DB on the web site.
While the application itself is difficult to load from a web page,
a web start application is simplicity itself - and probably a better
approach to the entire 'remote user access DB' problem.

Here is an example of a web started application/applet.
So my question is how can i run my applications on a Browser?

Start by answering the questions above, there is not
enough information yet, to tell for sure.
..Do I
have to install a web server such as apache?

No. If the problem is as we suspect, it is simply a matter
of ensuring the DB and applet codebase* is the same server.
* All the jar's for the code and drivers.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200705/1
 
C

christopher

yup. you need to download a JDBC driver and install it in the
classpath of the JVM your browser is using. sounds like the browser
might be using a different JVM.

(the other guy responding is an ass -- he knows the answer, and your
question was adequate to identify the problem)
 
L

Lew

yup. you need to download a JDBC driver and install it in the
classpath of the JVM your browser is using. sounds like the browser
might be using a different JVM.

(the other guy responding is an ass -- he knows the answer, and your
question was adequate to identify the problem)

Please do not top-post.

Are you sure? Doesn't the driver sit on the /server/ side, and is thus
completely independent of the browser? How the heck can having a JDBC driver
download affect anything?

I am no applet expert - for this kind of question Andrew Thompson has the best
knowledge.

Oh, Christopher - Andrew is not an ass. By telling the OP that you are
cutting them off from arguably their best source of information in this forum.
Who is the ass, someone helping the poster or someone poisoning the OP's
mind against that help and providing incorrect information?

To the OP - I suggest that you follow Andrew's suggestions. They will help you.

Andrew suggested:
No. If the problem is as we suspect, it is simply a matter
of ensuring the DB and applet codebase* is the same server.
* All the jar's for the code and drivers.

I think this answer is probably correct and Christopher's was just blowing
smoke up your, but Andrew would know.
 
G

Guest

Lew said:
Are you sure? Doesn't the driver sit on the /server/ side, and is thus
completely independent of the browser?

The original post strongly indicated that the JDBC code was client side.

Arne
 
A

Andrew Thompson

Arne said:
The original post strongly indicated that the JDBC code was client side.

We can guess all day and night. Until the OP answers
my first (and preferably subsequent) questions, I would
prefer to spend my time on problems for which the
necessary information is available to debug the problem.

For clarification - ultimately the driver code needs to be
available to the client. There are a number of ways to
ensure that.

You might take the approach used by the JMF installer -
which copies the relevant Jar's into the lib of every single
JRE it can find. Those jar's are then not only available
to the application, but also any other application that uses
the JRE - if newer JRE's are installed, the installer needs to
be run again.

OTOH - it is much simple for an applet* to provide the jar
containing the driver classes, specified** in the archives
attribute of the applet element.
This ensures the drivers are available to the applet in
whatever JRE it runs, but are not put on the classpath
of other applications, needlessly.

* or application/applet launched using web start
** ..in the jar element within the resources element.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200705/1
 
G

Guest

Andrew said:
We can guess all day and night.



If you think it is guessing to think:

#I am working on Project for a Java programming class.
#I have created some JDBC applications that query a MySQL database and
#they work perfectly when i run them through appletviewer as JApplets,
#or as JFrame. The only problem is that when i attempt to run them from
#the browser I get an error message something like "Database driver
#cannot be found" .

is client side not server side Java, then I think you have a problem !

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top