MySQL的的ExceptionInInitializerError的Java JDBC上启动 [英] MySQL ExceptionInInitializerError Java JDBC on Startup

查看:891
本文介绍了MySQL的的ExceptionInInitializerError的Java JDBC上启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个使用SQL数据库一个​​简单的小程序。

当我在Netbeans的本地使用此applet它运行良好没有问题,但是当我把它部署到Web我得到一个奇怪的错误。

我使用Java 1.6的本地和服务器部署我上运行的Java 1.6

我使用J2BC 5.1.22。

这是我的错误:

I am making a simple applet that uses an SQL Database.
When I use this applet locally on Netbeans it runs fine without a problem, yet when I deploy it to the Web I am getting a weird error.
I am using Java 1.6 locally, and the server I deploy on is running Java 1.6
I am using J2BC 5.1.22.
This is the error I get:

java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:315)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at FinalProject.DBConnect.<init>(DBConnect.java:29)
at FinalProject.TriviaApplet.init(TriviaApplet.java:61)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.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 java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70)

在code我用初始化驱动程序是:

The code I use to initialize the driver is:

        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection(connectionURL, "db", "pw");

没有任何一个有任何见解,为什么这是发生?

Does any one have any insight as to why this is occuring?

要添加,我的小程序会从另一个类的所有信息。 ^以上是从DBCONNECT类。这个类的一个实例被创建,该类做所有的工作DB。
正是出于这个要求作为一个小程序来完成。
我已经签署了我的两个罐子,包含JDBC驱动程序的lib罐子。

To add, my Applet gets all the information from another class. ^ The above is from DBConnect Class. An instance of this class is created, and this class does all the DB work. It was a requirement for this to be done as an applet. I have signed both my jar, and the lib jar containing the JDBC driver.

推荐答案

这是由于网络安全问题。 JDBC驱动程序是如何部署到客户端?你给他们足够多的许可?事实上,在小程序使用JDBC访问数据库的价值少。

it is due to the web security problem. how your JDBC driver is deployed to the client? do you give them enought permission? in fact, using JDBC in applet to visit the database in value-less.


  1. 它需要所有的客户端必须安装JRE和CLASSPATH JDBC驱动程序,你可以尝试用打包你的applet JDBC驱动程序在同一个JAR。

  1. it requires all the client must have JRE installed and JDBC driver in CLASSPATH, you can try to package the JDBC driver with your applet in a same JAR.

它格兰特需要政策的修改在每个地方JRE套接字连接。

it need the policy modification by grant the socket connection in every local JRE.

许可java.net.SocketPermission10.6.1.16:1521,连接起来,解决;

这使该解决方案几乎无用。

that make this solution nearly useless..

这篇关于MySQL的的ExceptionInInitializerError的Java JDBC上启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆