Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: acc
ess denied (java.util.PropertyPermission oracle.jserver.version read)

hi,

i m building an online examination application. The code is getting complied .but it throws an exception.Below i m pasting d code as well as exception.plz help me.

It is a simple program for login. It matches d password with password field sored in table type.I m using oracle at backend.

Exception:

Exception in thread "AWT-EventQueue-1" java.security.AccessControlException: acc
ess denied (java.util.PropertyPermission oracle.jserver.version read)
        at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
        at java.security.AccessController.checkPermission(AccessController.java:
546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:12
85)
        at java.lang.System.getProperty(System.java:650)
        at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:433)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at login1.actionPerformed(login1.java:129)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
95)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6263)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6028)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
 
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.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)
import java.sql.*;

import java.awt.Container;
 									 
import javax.swing.JButton; 
				
import javax.swing.JLabel;

import javax.swing.JComboBox;

import javax.swing.JPasswordField;

import javax.swing.JOptionPane;

import java.util.Arrays;

import java.awt.*;

import javax.swing.*;

import java.awt.event.ActionEvent;
			
import java.awt.event.ActionListener;

import java.awt.event.*;

/*
<applet code= "login1" width=500 height=500>
</applet>
*/

public class login1 extends JApplet implements ActionListener 
{
	
	private static String Login = "Login";

	private JPasswordField password;

	private JComboBox cbotype;

	JButton btnlogin;

	public void init()
	{
		Container cnt=getContentPane();		

		btnlogin =new JButton("Login");

		JLabel lbltype=new JLabel("User type");

		JLabel lblpassword=new JLabel("Password");

		String type[]={"Student","Administrator","Registrar"};

		cbotype= new JComboBox(type);

		password= new JPasswordField();

        	password.setEchoChar('*');

			

		cnt.setLayout(null);

		cnt.add(lbltype);

		cnt.add(lblpassword);

		cnt.add(btnlogin);

		cnt.add(cbotype);

		cnt.add(password);



		lbltype.setBounds(50,50,90,20);

		lblpassword.setBounds(50,110,90,20);

		cbotype.setBounds(150,50,90,20);
		
		password.setBounds(150,110,90,20);

		btnlogin.setBounds(100,170,90,30);
		


		cbotype.addActionListener(this);
		
		btnlogin.addActionListener(this);

		password.addActionListener(this);

		password.setActionCommand(Login);

		cbotype.setSelectedIndex(0);


		
		setSize(500,500);

	
	}

	public void actionPerformed(ActionEvent e) 
	{	 
		String cmd = e.getActionCommand();

		if (Login.equals(cmd)) 
		{

        		char[] input = password.getPassword();

			String str =(String) cbotype.getSelectedItem();
        
	
			try
			{
	
				Class.forName("oracle.jdbc.driver.OracleDriver");

				String url="jdbc:oracle:thin:@localhost:1521:xe";

				String username="hr";

				String password="hr";

				Connection connection=DriverManager.getConnection(url,username,password);

				Statement statement=connection.createStatement();

				String query="Select PASSWORD from type where user_type= '" + str +"'";

				ResultSet resultset=statement.executeQuery(query);
		
				while(resultset.next())
				{
					
					char data[] = resultset.getString(1).toCharArray();

					if( Arrays.equals (data,input))
					{
						JOptionPane.showMessageDialog(btnlogin,"Success! You typed the right password.");
						
					}
					else
					{
						JOptionPane.showMessageDialog(btnlogin,"Invalid password. Try again.","Error Message",JOptionPane.ERROR_MESSAGE);
					}
				

				}

				connection.close();

			}
			catch(ClassNotFoundException cnfe)
			{
	
				System.out.print("ERROR LOADING DRIVER: " + cnfe);

			}
			catch(SQLException se)
			{
				System.out.print("SQL Exception " + se);

			}
		
  		} 				
 		
				
 		

	}
	



}

Applets need permission to do most things. I guess your code is trying to access a Property and it is not allowed to.
To give an applet permission you need to put it in a signed jar
or make changes to the .java.policy file on the client machine.

Or change your logic so the server side code does the DB lookup.

i m struck on it from many days,,,plz help

Edited 6 Years Ago by har58: n/a

Applets need permission to do most things. I guess your code is trying to access a Property and it is not allowed to.
To give an applet permission you need to put it in a signed jar
or make changes to the .java.policy file on the client machine.

Or change your logic so the server side code does the DB lookup.

thnks friend ,,i m new to java ,,

i hv tried all possible means,,, i could do,,plz xplain it a little more

Applets need permission to do most things. I guess your code is trying to access a Property and it is not allowed to.
To give an applet permission you need to put it in a signed jar
or make changes to the .java.policy file on the client machine.

Or change your logic so the server side code does the DB lookup.

plz help me do it,,how to put it in signed jar,,?

u r right friend,i read somwhere with applets it is difficult to get access to local drives,,,n we need to do it through signed jar,,,,

but can u xplain how to do it,,?

in my program too, i hv jdbc driver in my local drive,,,,thats is why it is not able to access it,,,

This article has been dead for over six months. Start a new discussion instead.