×

Loading...

Topic

  • 工作学习 / IT技术讨论 / 请大家帮助看看!(JAVA 问题)
    用JAVA APPLET编的数据库的前台的管理和维护。在我的笔记本上调试及发布
    都没问题,但将代码放到SERVER上就不行?!
    笔记本和SERVER的软件配置几乎一样。

    REDHAT LINUX6.1
    APACHE SERVER
    JDK 1.2
    MYSQL
    MM.MYSQL.JDBC-1.2C( MYSQL的JDBC接口驱动)

    在SERVER上运行
    HTTP://MYSERVER/MYAPPLET.HTML
    现象是
    SQLException:java.sql.SQLException:Sever configuration denies access to
    source

    (这还有点头绪,可能是MYSQL的配置有问题)

    在CLIENT上运行
    HTTP://MYSERVER/MYAPPLET.HTML
    现象是
    Can't find Database driver class: java.lang.ClassNotFoundException:
    org/gjt/mm/mysql/Driver
    (真奇怪,现象是没设CLASSPATH,不过我是设了的,并且PRINTENV也有我设的
    CLASSPATH,我还考到/USR/LOCAL/JDK1。2/LIB一份呀!而且在SERVER上运行,就
    没报这错?)

    真是气人,程序都编完了,就是发布不了!公司还急着要!(对了,SERVER上其他的APPLET没事)
    请各位给点意见!!!

    谢谢拉
    • Do you use the "package" ?
      If yes, check the path which you use to call the class.

      For example, if your program looks like this:

      ...
      package proj1.sub2
      ....
      public class abc
      ....

      Then you should use:
      java proj1.sub2.abc
      instead of just:
      java abc

      This is the problem I once met, hope it makes some sense for you.
    • 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
      • Thanks. Pls come in!
        謝謝各位的幇忙,在SERVER上以調試成功,問題是我的NOTEBOOK上的APACHE 和MYSQL是用靜太編譯的(這樣MYSQL支持JDBC調用),
        而SERVER是動太編譯的,所以現實那行錯誤信息(從新編譯APACHE和MYSQL就可以了)。至于CLIENT的問題依舊(哀),正在苦苦探索中。
        TO JABBER: 十分感謝YOUR的回答, 不好意思的説這個系統是我設計的,主要是也就2-3的CLIENT端(就用APPLET,並且我比較熟APPLET)。
        來日本4個月,是家小公司我是從站點數據庫的設計,到編程(HTML,PHP3,APPLET),到DNS,SENDMAIL的配置,幾乎全是我一個人干的(都快
        五項全能了! 哈哈)。 干的活挺全的,因為我想向JAVA發展,公司又沒有個JAVA大拿(不好意思的説我現在就是公司的技術負責,管我自己和2個
        也就是美工級別的日本程序員),以後要多想YOU學習。明年我也去多,説不准我可以參加YOUR的JAVA培訓那!
        還有我先用PHP對付了個暫時的程序,現讓他們用這,我這在調這可恨的APPLET。最後因為這漢字打不出‘YOU’,所以寫英文了,我的英文很濫,
        聊長的,就只好上中文的。

        Truly
        fly_eagle
        • You guy are too humble
          Fly_eagle,

          Nobody knows everything. Actually, you are already a mature Java developer. I say so because you can understand my responses.
          We Java folks are fighting agaist bugs everyday....

          Be sure to improve your English. One of my friends is from Japan and he is a PhD from Tokyo Univeristy. His english is terrible. He first immigrated to Canada 4 years ago. He taught himself some VB and began to hunt for jobs... many sad stories. Later he came to USA and attended some training schools. Then he beagn to hunt for jobs ago. He experienced about 49 job interviews and got an offer. He earns much less than he did in Japan.... Several years have passed but his English is still awkward. I feel very diffiuclt to understand his English because of his accents.

          Hope you can improve your English as much as possible before you come to Canada.
      • It's possible to setup a connection between applets and the remote database. In this case, your applet might have to d/l the JDBC classes everytime you run the applet.
        • Thanks,I agree with you.Also after check the apache server error_log,
          I fix that problem,but
          my applet working fine in NE4.5 using the mm-mysql-Driver for establishing connection to a MYSQL db running on LINUX does not work in IE5. With the same .class-files and HTML-Code the IE5 produces a "No suitable driver" caused SQLException when trying to connect to db. Maybe I will give up!
          • Handicapped JVM from Microsoft
            本文发表在 rolia.net 枫下论坛I think you know the legal dispute between Sun and Microsoft.

            Microsoft has never complied the JAVA specification. For instance, its J++ looks like a Java but it includes some proprietary classes. In addition, Microsoft Java Virtual Machine (JVM) does not support Java RMI (I guarantee you!) . Since Sun's lawsuit agaist Microsoft, the latter has stopped updating its JVM (called jview). So IE5 is leading in supporting XML files but its JVM is still an old version.

            A lot of JDBC drivers used Java RMI as underlying protocol to connect DB. If your JDBC driver for MySQL used RMI, you have no way to make your Applet work in IE5.

            To prove or disprove my guess work, you may download a Java-Plugin from Sun's site and install it on your client machine and configure it to make it work with IE5. Then,
            test your code. I believe it will work. Then, Uninstall Java-Plugin and try again using IE5.

            In case you are not familiar, I remind you can check all the error messages for Applet by visiting view|Java Console in IE5, or by visiting Communicator|Tools|Java Console.

            Since you are lead developer, I suggest you download a Jakarta-Tomcat and use Java Servlets to access DB and publish dynamic contents. We had better avaoid to use Applets.

            Good luck.更多精彩文章及讨论,请光临枫下论坛 rolia.net
            • You are right !
              You are right.After setup the Java plug-in, my applet works both IE5 and NN.
              Unfortunatly , my boss likes the temporary program which is coded by PHP
              very much. Thus I have to give up this applet. Also I already setup the Tomcat
              two months ago, just no time to study how to code Java Servlets.
              Appreciate your help!