Forums Register Login
applet raise an exception when i insert data to mysql database table
hello every one

i wrote one database program for inserting something to mysql database table from simple java application. it is working properly. the data will be updated.

but i wrote the same application using applet. it did not work properly. because i do not know. it raised an exception when i update the data from applet program.

database connection coding:

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/<database name>","<username>","<password>");
Statement stmt = con.createStatement();

The above database connection coding is common to all application like swing,applet and .........

now tell me
1. why applet raise an exception when i insert data from applet to mysql?
2. An exception is telling that the the specified driver is not Register yet.
3. The exception statement is
Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at applet_pack.dbcheck$1.actionPerformed(dbcheck.java:62)
at java.awt.Button.processActionEvent(Button.java:392)
at java.awt.Button.processEvent(Button.java:360)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:235)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:288)
at java.lang.Thread.init(Thread.java:332)
at java.lang.Thread.<init>(Thread.java:377)
at java.util.TimerThread.<init>(Timer.java:456)
at java.util.Timer.<init>(Timer.java:71)
at java.util.Timer.<init>(Timer.java:122)
at com.mysql.jdbc.ConnectionImpl.<clinit>(ConnectionImpl.java:208)
... 15 more

Reply me with the correct solution or answer

Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)

This is the problem. The driver is doing something -apparently thread-related- that is not allowed in applets. Another thing to keep in mind is that applets can only connect to the machine where they were served from. So if the DB is on "localhost", then the applet would need to have been run from a "http://localhost:.../..." address.

See HowCanAnAppletReadFilesOnTheLocalFileSystem for the two principal ways around that; signing the applet is probably easier if it is to be used by several people.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 1772 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jun 24, 2018 18:37:10.