gpt4 book ai didi

java - 带有 swing mysql 和配置文件的小程序在 eclipse 中工作但在浏览器中失败

转载 作者:行者123 更新时间:2023-11-29 13:38:48 24 4
gpt4 key购买 nike

嗨,这可能是因为我是个菜鸟,但我已经努力让它工作好几天了,所以希望有人可以帮助我......

想法:对于 Java 培训,我需要制作一个 Java applet 来从(本地主机)MySQL 数据库读取和写入数据。该数据库中的设置必须来自 config.ini 文件。

该应用程序在 Eclipse 中作为 applet 和 java 应用程序运行良好。它也可以作为可执行 jar 文件正常运行。

但是我无法让它作为小程序运行...:(。

我遇到的第一个错误是关于读取 config.ini 文件。我预计这种情况会因为安全限制(io)而发生。这是需要解决的问题,但目前不是我主要关心的问题。

为了查看其余部分是否有效,我跳过了 loadIni 类。然后我得到一个:驱动程序未找到异常。我通过将 mySQL jar 作为存档加载到我的小程序 () 中解决了这个问题。

但现在我迷路了......

当我在浏览器中启动小程序时,我在控制台中收到以下错误:

java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Kreta.DBConnection.<init>(DBConnection.java:39)
at Kreta.AfhaalMenus.<init>(AfhaalMenus.java:21)
at Kreta.test2.<init>(test2.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission"
"file.encoding" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70)
... 31 more

我真的希望有人能引导我走向正确的方向。

最佳答案

小程序不允许执行许多操作,包括文件 I/O 和各种网络任务;因为您的小程序正在尝试执行此操作。您可能需要签署您的小程序。

检查此引用

http://www.coderanch.com/how-to/java/HowCanAnAppletReadFilesOnTheLocalFileSystem

关于java - 带有 swing mysql 和配置文件的小程序在 eclipse 中工作但在浏览器中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18402033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com