HI all I am running an applet in which i am connecting it with sql7.0. I made a permission from the jdbcodbc sriver. My applet runs very well but when i enter some data in the text box and i click on the button to let the data pass to the databasei get the following error: java.security.AccessControlExveption: access denied(java.lang.RuntimePermission accessClassPackage.sun.jdbc.odbc) below is my code for the above: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class Example extends JApplet { JPanel perPanel; JLabel lblAppId; JLabel lblAppName; JLabel lblAppPosition;
String appName = txtAppName.getText(); if (appName.length() == 0) { getAppletContext().showStatus("Applicant Name cannot be blank"); return; } String position = String.valueOf(comAppPosition.getSelectedItem()); getAppletContext().showStatus(" "); }
Object source = e.getSource(); if (source == butAccept) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con; con = DriverManager.getConnection("jdbc dbc:Example","sa",""); PreparedStatement stat=con.prepareStatement("insert into Example(cAppId,vAppName,vAppPosition)values(?,?,?)"); stat.setString(1,txtAppId.getText()); stat.setString(2,txtAppName.getText()); stat.setString(3,(String)comAppPosition.getSelectedItem()); stat.executeUpdate(); } catch (Exception exception) { System.out.println("Error encountered while entering data in the database:"+ exception); } } } } } please reply soon Thank You Jitin.Rathod [This message has been edited by Jitin Rathod (edited May 09, 2001).] [This message has been edited by Jitin Rathod (edited May 09, 2001).] [This message has been edited by Jitin Rathod (edited May 09, 2001).]
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
IE is not going to let an applet access a database unless it is certified. Try running it using AppletViewer and I bet it will work fine. You need to rethink how you want your applet to access the database... buy a certificate, update the policy data on every users PC, or use a servlet as a database proxy.
Hi Thomas Thanks alot for ypur reply. As you said that i do not run my applet in ie rather run it in appletviewer, but Thomas i am running my applet through appletviewer then i have got that error. Thomas one more thing is can you please just make it more clear about buying the certificate. And i am sorry again Thank You Jitin.Rathod
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
What database are you using? This seems to work fine for me in Appletviewer.
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
If you are interested in creating signed applets, the book Java Cryptography has a chapter on creating signed applets.
Xavier VS
Greenhorn
Joined: May 11, 2001
Posts: 7
posted
0
Hi, The reason is you have to set permission in java.policy file. It can be set by using policytool.Its a tool which comed along with JDK. U have to grant permission for accessing the database. Xavier
Jitin Rathod
Greenhorn
Joined: Apr 25, 2001
Posts: 19
posted
0
Hi Xavier Thanks a lot for your reply. I tried what yoyu had instructed me to do but i am confused which permission should i select from the Permission drop down, what should be the target name and what should be the Action. Regards Jitin.Rathod
Jitin Rathod
Greenhorn
Joined: Apr 25, 2001
Posts: 19
posted
0
Hi Xavier please try to finish off solving my problem. Thanks Jitin.Rathod
Jitin Rathod
Greenhorn
Joined: Apr 25, 2001
Posts: 19
posted
0
Please can any help me solving my problem
shivanath yerra
Greenhorn
Joined: Jan 17, 2002
Posts: 14
posted
0
I think the problem with the getConnection method where you had not given the password. please check it with proper password.
Jitin Rathod
Greenhorn
Joined: Apr 25, 2001
Posts: 19
posted
0
Thanks Shivanath, for ur reply. I do not have a password for my connection so what should i do now.
Jitin Rathod
Greenhorn
Joined: Apr 25, 2001
Posts: 19
posted
0
please try solving out my problem
Jitin Rathod
Greenhorn
Joined: Apr 25, 2001
Posts: 19
posted
0
Thanks all for the great guidance. The problem was from my side only. I did not make a .java.policy file. But even i could not help i had not been told about it in my classes Thank You, Regards JITIN.RATHOD