将jdbc驱动打包到applet的jar中。
不过更好的办法是用servlet。具体的:oracle ->JDBC->servlet->HTTP->applet(或者直接到页面)

解决方案 »

  1.   

    我先说明一下,我在APPLET里加ORALCE连接主要是要在INTRANET中提供B/S方式的统计,有的统计可能要很花很长时间,如果用SERLVET怕没有响应。
    TO,yangzi,我用了JAR,但好象如何CLIENT没装ORALCE CLIENT就不能正确执行,装了就OK,我把我的代码贴在下面了。
    package chat;import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.sql.*;public class DbApplet extends Applet {
      boolean isStandalone = false;
      Button button1 = new Button();
      Label label1 = new Label();
      /**Get a parameter value*/
      public String getParameter(String key, String def) {
        return isStandalone ? System.getProperty(key, def) :
          (getParameter(key) != null ? getParameter(key) : def);
      }  /**Construct the applet*/
      public DbApplet() {
      }
      /**Initialize the applet*/
      public void init() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      /**Component initialization*/
      private void jbInit() throws Exception {
        button1.setForeground(Color.red);
        button1.setLabel("button1");
        button1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button1_actionPerformed(e);
          }
        });
        label1.setText("label1");
        this.setBackground(Color.white);
        this.add(button1, null);
        this.add(label1, null);
      }
      /**Get Applet information*/
      public String getAppletInfo() {
        return "Applet Information";
      }
      /**Get parameter info*/
      public String[][] getParameterInfo() {
        return null;
      }  void button1_actionPerformed(ActionEvent e) {
          Connection JDBCConn; try {
           label1.setText("sql .....");
                DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
                     label1.setText("registerDriver .... ");
    //            JDBCConn  =DriverManager.getConnection ("jdbc:oracle:thin:@211.95.170.29:1521:TF4","system", "manager");
                JDBCConn  =DriverManager.getConnection ("jdbc:oracle:thin:@192.168.198.101:1521:TF1","oradep", "oradep123");
                label1.setText("getConnection");
                JDBCConn.close();
      }
          catch (Exception sqle) {
                 label1.setText("error");
    //            System.out.println("connect db error:"+sqle.toString());           // return null;
          }
          label1.setText("sqlok");
      }
    }
      

  2.   

    Your method is too complex! I connect to oracle very simply.
    1.Copy class111.jar to java\lib. (class111.jar can be found in the oracle cdrom.)
    2.In the project properties add it to libary.
    3.code:
      try {
       Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
       DriverManager.setLoginTimeout(10);
       Connection con=DriverManager.getConnection   ("jdbc:oracle:thin:@110.12.1.2:1521:dbname,userID,password);     
    }
    catch(Exception e){
      system.out.println(e.getMessage());
    }
     
      

  3.   

    zebulon(zebulon) 的方法的确是对的
    如何把他们放到web服务器上发布那??
      

  4.   

    这也行??不怕代码泄漏!!!用在applet中安全否!!