Results 1 to 4 of 4
  1. #1
    iNterfector is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Applet connecting to database error

    Hey all, let me just say "Hi" real quick, I am new on this forum, I am from the Netherlands, 25 yrs old and am busy with a java-course.
    I wrote a java-program with a gui to interact with a database on my localhost. It works the way it should when I run it in my java-editing program("eclipse"), however when I try to run it as an applet in a web-page I get a number of errors, the errors are the following:


    java.lang.RuntimeException: java.lang.ExceptionInInitializerError
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ExceptionInInitializerError
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:286)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at kreta.Connector.<init>(Connector.java:31)
    at kreta.Editor.<init>(Editor.java:10)
    at kreta.Framework.<init>(Framework.java:30)
    at kreta.AppletClass.<init>(AppletClass.java:15)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(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(Unk nown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unkn own Source)
    at java.lang.System.getProperty(Unknown Source)
    at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.ja va:70)
    ... 28 more
    Exception: java.lang.RuntimeException: java.lang.ExceptionInInitializerError


    So something to do with the NonRegisteringDriver.connect I guess..
    In my own code AppletClass makes a Framework, Framework makes an Editor and Editor makes a Connector instance, the code where it goes wrong in Connector is the following:

    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    } catch (Exception e) {
    e.printStackTrace();
    }
    try {
    connectie = DriverManager.getConnection("jdbc:mysql://" + this.host + "/" + this.database + "?user=" + this.user + "&password=" + this.password);
    System.out.println("Er is verbinding");
    } catch (Exception e) {
    e.printStackTrace();
    }

    line 31 is the line starting with "connectie".

    The appletcode in my html looks like this:

    <applet name="KretaApplet" code="kreta.AppletClass.class" codebase="." archive="mysql-connector-java-5.1.18-bin.jar, KretaApp.jar" WIDTH=1024 HEIGHT=700>

    I hope this provides enough information for anyone to tell me what I am doing wrong and how I can fix this, thanks in advance.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Applet connecting to database error

    java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)
    One part of your problem is that applet does not have permission to read.
    Unsigned applets are restricted on what they can do. There is a discussion on how to use applets in the tutorial.
    Go to this site and Find Applet. There are several sections about applets
    The Really Big Index

  3. #3
    iNterfector is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: Applet connecting to database error

    Thx, I really appreciate the quick answer.
    However I think this error you are referring to is caused by the server not getting my login-information while my program is still trying to get information from it.
    I did indeed get the permission problem you speak of when I tried to read a config file on my harddrive for the settings of host/database and username.
    I'd really like to get this connection/driver problem out of the way first so I can focus on the other potential flaws in my coding, thx.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Applet connecting to database error

    For better debugging output add a println before your calls to printStackTrace.
    It looks like when you catch one exception, you call printStackTrace and then continue to some more code which will probably continue to throw exceptions and on and on.
    When you get the first exception, you should exit the method unless you can fix the problem in the catch block.

Similar Threads

  1. connecting Ms-access database with java applet
    By balaKannan in forum New To Java
    Replies: 1
    Last Post: 12-23-2010, 01:16 PM
  2. Connecting JSP with database
    By ramachandran in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 05-13-2009, 07:15 AM
  3. Connecting database from Applet
    By Preethi in forum New To Java
    Replies: 5
    Last Post: 05-21-2008, 09:14 AM
  4. Connecting to a database
    By peiceonly in forum New To Java
    Replies: 2
    Last Post: 04-06-2008, 03:28 PM
  5. Error while connecting to a database
    By Fukushuusha in forum JDBC
    Replies: 2
    Last Post: 12-16-2007, 10:40 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •