public class SetupExam extends Applet {
/**
*
*/
private static final long serialVersionUID = -4106575420788590877L;
private JTextField td_tf;
private JTextField mfeq_tf;
private JTextField nmfe_tf;
/**
* Create the applet.
*/
public SetupExam() {
setLayout(null);
JLabel main_l = new JLabel("Exam");
main_l.setHorizontalAlignment(SwingConstants.CENTER);
main_l.setFont(new Font("Arial", Font.BOLD, 15));
main_l.setBounds(7, 4, 601, 42);
add(main_l);
JLabel cat_l = new JLabel("1.Category");
cat_l.setFont(new Font("Arial", Font.PLAIN, 15));
cat_l.setBounds(16, 80, 162, 32);
add(cat_l);
JLabel td_l = new JLabel("2.Time Duration");
td_l.setFont(new Font("Arial", Font.PLAIN, 15));
td_l.setBounds(16, 130, 162, 32);
add(td_l);
JLabel noq_l = new JLabel("3.Number of Questions");
noq_l.setFont(new Font("Arial", Font.PLAIN, 15));
noq_l.setBounds(13, 184, 165, 32);
add(noq_l);
JLabel mfeq_l = new JLabel("4.Marks for each Question");
mfeq_l.setFont(new Font("Arial", Font.PLAIN, 15));
mfeq_l.setBounds(13, 236, 178, 32);
add(mfeq_l);
JLabel nmfe_l = new JLabel("5.Negtive Mark For Each");
nmfe_l.setFont(new Font("Arial", Font.PLAIN, 15));
nmfe_l.setBounds(13, 293, 178, 32);
add(nmfe_l);
JComboBox cat_combo = new JComboBox();
cat_combo.setEditable(true);
cat_combo.setBounds(237, 80, 208, 32);
add(cat_combo);
td_tf = new JTextField();
td_tf.setBounds(237, 130, 208, 32);
add(td_tf);
td_tf.setColumns(10);
mfeq_tf = new JTextField();
mfeq_tf.setColumns(10);
mfeq_tf.setBounds(237, 236, 208, 32);
add(mfeq_tf);
nmfe_tf = new JTextField();
nmfe_tf.setColumns(10);
nmfe_tf.setBounds(237, 293, 208, 32);
add(nmfe_tf);
JSpinner noq_spin = new JSpinner();
noq_spin.setModel(new SpinnerNumberModel(10, 1, 100, 1));
noq_spin.setBounds(237, 180, 208, 32);
add(noq_spin);
JButton sbmt_btn = new JButton(mfun());
sbmt_btn.setFont(new Font("Arial", Font.PLAIN, 12));
sbmt_btn.setBounds(228, 383, 126, 41);
add(sbmt_btn);
}
public String mfun()
{
try
{
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection con=DriverManager.getConnection("jdbc:ucanaccess://C:\\workspace\\exam.mdb");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("Select * from exam_setup");
while (rs.next())
{
//System.out.println(rs.getString(3));
return rs.getString(3);
}
} catch (Exception ex)
{
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
return null;
}
}
I am using Ucanacess 4.0.1.
Before this I checked connectivity by inserting data in table exam through a Java program but it's not working when I added the code in my applet. I used following command to run applet
appletviewer ExamSystem.html
output:
Exception: UCAExc:::4.0.1 access denied ("java.util.logging.LoggingPermission" "control")
The appletviewer
utility apparently runs the applet code in a restricted environment, most likely similar to the "sandbox" that would be used for an unsigned applet. UCanAccess was not designed to run in such an environment.