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;
}
}
我正在使用Ucanacess 4.0.1。
在此之前,我通过Java程序在表格考试中插入数据来检查连接性,但是当我在applet中添加代码时,它无法正常工作。 我使用以下命令来运行applet
appletviewer ExamSystem.html
输出:
例外:UCAExc ::: 4.0.1访问被拒绝(" java.util.logging.LoggingPermission"" control")
答案 0 :(得分:0)
appletviewer
实用程序显然在受限制的环境中运行applet代码,很可能类似于" sandbox"那将用于unsigned applet。 UCanAccess不是为在这样的环境中运行而设计的。