Results 1 to 4 of 4
- 11-30-2011, 12:59 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
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.
- 11-30-2011, 01:12 PM #2
Re: Applet connecting to database error
One part of your problem is that applet does not have permission to read.java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding 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
- 11-30-2011, 01:27 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
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.
- 11-30-2011, 01:35 PM #4
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
-
connecting Ms-access database with java applet
By balaKannan in forum New To JavaReplies: 1Last Post: 12-23-2010, 12:16 PM -
Connecting JSP with database
By ramachandran in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 05-13-2009, 06:15 AM -
Connecting database from Applet
By Preethi in forum New To JavaReplies: 5Last Post: 05-21-2008, 08:14 AM -
Connecting to a database
By peiceonly in forum New To JavaReplies: 2Last Post: 04-06-2008, 02:28 PM -
Error while connecting to a database
By Fukushuusha in forum JDBCReplies: 2Last Post: 12-16-2007, 09:40 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks