0

アプレットに問題があります。アプレットビューアでは正常に動作しますがWeb browser、例外がスローされます。

例外の詳細:

`SQLException: No suitable driver found for jdbc:mysql://s46.eatj.com:3307/cmentarz
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at JDBC.LogIn(JDBC.java:49)
at AdminPanelLogIn$1.actionPerformed(AdminPanelLogIn.java:64)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)`

JARmakerを使用してjarファイルに署名しました。

私のgetConnectionメソッドコード:

public Connection getConnection() throws SQLException {

    try {
        Class.forName("com.mysql.jdbc.Driver");
    } catch (java.lang.ClassNotFoundException e) {
        System.err.print("ClassNotFoundException: ");
        System.err.println(e.getMessage());
    }

    try {
        con = DriverManager.getConnection(url, userid, password);
    } catch (SQLException ex) {
        System.err.println("SQLException: " + ex.getMessage());
    }
    return con;
}

Userid、アプレットビューアで動作するため、正しいですpasswordurl

static String url = "jdbc:mysql://s46.eatj.com:3307/cmentarz";

それで、何が問題になる可能性がありますか?

4

1 に答える 1

0

MySQLブラウザで実行しているときに、アプレットがjarを使用できることを確認してください。appletこれは、 (またはobject)タグで指定できます。

<applet code="org.package.MyApplet" width="800" height="600" archive="myappletjar.jar,mysql-connector-java-5.1.6-bin.jar">
</applet>

また、ダウンロードできるように、jarファイルがアプレットのjarファイルと同じ場所にあることを確認してください。

于 2013-01-13T16:03:38.797 に答える