how to access database after creating Frontend UserInterface using Applets.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   KrishnaMurthy_G
Posted On:   Monday, May 22, 2006 02:41 AM

I have created a small application in which the front end is designed using applets and awt in java .The application accepts StudentID,Name,Qualification and percentage and writes it to the database.I have used 2 buttons add and cancel.Action Listeners are added to this code.In the actionPerformed function code is like this: public void actionPerformed(ActionEvent ae) { String s=ae.getActionCommand(); if(s.equals("ADD")) { try { String sid=txtsid.getText(); String sname=txtsname.getText(); String squal=q.getSelectedItem(); String sper=txtper.getText(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager   More>>

I have created a small application in which the front end is designed using applets and awt in java .The application accepts StudentID,Name,Qualification and percentage and writes it to the database.I have used 2 buttons add and cancel.Action Listeners are added to this code.In the actionPerformed function code is like this:

public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
if(s.equals("ADD"))
{

try
{
String sid=txtsid.getText();
String sname=txtsname.getText();
String squal=q.getSelectedItem();
String sper=txtper.getText();

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:std");
con.setAutoCommit(false);
PreparedStatement ps=con.prepareStatement("insert into student values(?,?,?,?)");
ps.setString(1,sid);
ps.setString(2,sname);
ps.setString(3,squal);
ps.setString(4,sper);
int i=ps.executeUpdate();
con.commit();
Label l1=new Label("Values entered");
add(l1);
con.close();

}
catch(Exception e)
{
System.out.println(e);
}

}
else if(s.equals("CANCEL"))
{
txtsid.setText("");
txtsname.setText(" ");
txtper.setText(" ");
}
}
}

But I am getting an Exception :java.security.AccessControlException:access Denied.Database is not updated.Program is not working .Please tell me how to solve
this problem.Waiting for your reply.

   <<Less
About | Sitemap | Contact