×

Loading...

Some thoughts about your problems

本文发表在 rolia.net 枫下论坛Dera fly_eangle,

It seams to me that your architecture lacks sth. I hope I misunderstood you here.

Apache is simply a web server. It can serve the browser static contents only, such as
.html and .gif files. If we need to serve dynamic contents, we HAVE TO introduce
server-side extensions, e.g., CGI programms
and servlet engine. If we use MIIS, we can also use ASP technology. However, in the configuration list you gave, there are no CGI programms or servlet engines. I really hope you missed the item I mentioned. Otherwise,
your Apache server has no way to serve the contents from MySQL DB.

No let me try to describe how Applets work. Of course, most Java programmers think this is trivial. Let me assume that Jabber's browser is accessing your Apache server.
On your server machine, you run a MySQL and an Apache. Under you Apache server, you have put HTML file and Jar file for applets. Let me remind you that you have put JDBC driver under ../JDK1.2/LIB.

My browser sends a request to your Apache server and the latter sends your HTML file to my browser. As my browser parses this HTML, it finds <APPLET> tag and consequently downloads
your Jar file. Of course, your jar file is depend upon a lot of library classes, such as
java.lang.String, java.applet.Applet,...of course, and JDBC driver classes (presumably org.gjt.mm.mysql.Driver).
The JVM in my browser is smart. It finds
that some classes (from JDK) are system classes, so it does not bother to download
them from your Apache. However, it does need download JDBC driver from your Apache because it fails to find it after searching my machine according to CLASSPATH. This is why you got java.lang.ClassNotFoundException.

You may wonder how things went smoothly on your notebook. As you tested your code, you physically put Apache server and browser on the same machine and you used the localhost. Your browser found JDBC driver according to CLASSPATH from under ../JDK1.2/LIB. In other words, your browser did not download JDBC. It instead loaded from the local machine.

One remedy exists. You need bind JDBC driver class with your Applet because your Applet needs to use it. Even you follow my suggestion here, I am still sudpicious whether your code will work. The reasoning follows.

According to your error message, I observed that you have your Applet to communicate with remote DB at your machine using JDBC technology. We know Java Applet works subject to SecurityManager. By default, Applet can establish network connections with the server from which it comes, this should be no problem if the connection is
based on HTTP or TCP/IP. For JDBC connection, some strange protocols such as jdbc:oracle, jdbc:db2 are used. If the Applet can successfully establish the JDBC connections need your testing (I have no hands-on experience in having Applet communicate with DB.)

I think that the architect in your project is awkward. Even your code works after you make JDBC driver available to the client, the performace will be poor. If it is not you who made the design, you should be ready for finger-pointing.

My wording may not be accurate but I don't have time to refine my posting. I hope you are not offended by me.

Good luck.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Sign in and Reply Report

Replies, comments and Discussions: