java随机出题源代码 java测试数据随机生成( 三 )


return;
} else
{
printwriter.println("center");
printwriter.println("动态组卷成功!br");
printwriter.println("共生成了 " + i + " 套试卷br");
printwriter.println("a href=https://www.04ip.com/test/admin/genpaper.jsp单击这里设置生成试卷的参数/a");
printwriter.println("/center");
return;
}
}
public boolean open_db(String s)
{
try
{
new OracleDriver();
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ora9", "scott", "tiger");
stmt = conn.createStatement();
}
catch(Exception exception)
{
return false;
}
return true;
}
public boolean setParams(String s)
{
String s1 = "";
try
{
String s2 = "select count(questionid) as countquestionidfrom test_question_lib ";
s2 = s2 + "where classid='" + s + "'";
rs = stmt.executeQuery(s2);
rs.next();
total_question_num = rs.getInt("countquestionid");
s2 = "select totalques from test_classinfo ";
s2 = s2 + "where classid='" + s + "'";
rs = stmt.executeQuery(s2);
rs.next();
total_question_in_paper = rs.getInt("totalques");
}
catch(Exception exception)
{
return false;
}
return true;
}
public boolean verify_QuertionLib()
{
return total_question_num =total_question_in_paper;
}
public boolean updateOtherTable(int i, String s)
{
int j = 0;
String s1 = "update test_classinfo set totalpaper=totalpaper+";
s1 = s1 + i + " where classid='" + s + "'";
try
{
j = stmt.executeUpdate(s1);
}
catch(Exception exception)
{
return false;
}
return j == 1;
}
public int genPaper(int i, String s)
{
boolean flag = false;
boolean flag1 = false;
boolean flag2 = false;
boolean flag3 = false;
String s1 = "";
try
{
int ai[] = new int[total_question_num];
int i1 = 0;
boolean flag4 = false;
String s2 = "select max(paper_id) as max_paper_id from test_paper_lib";
【java随机出题源代码 java测试数据随机生成】rs = stmt.executeQuery(s2);
rs.next();
int j = rs.getInt("max_paper_id") + 1;
s2 = "select questionid from test_question_lib where classid='" + s + "'";
for(rs = stmt.executeQuery(s2); rs.next();)
ai[i1++] = rs.getInt("questionid");
for(int k1 = 0; k1i; k1++)
{
int k = ai.length; //8
for(int l1 = 0; l1total_question_in_paper; l1++)
{
// int ai[] ={1 ,3 , 5 ,9 , 56,30 96 ,25};
int j1 = (int)Math.floor(Math.random() * (double)k); // 4
String s3 = "insert into test_paper_lib values(";
s3 = s3 + "test_seq_paper.nextval," + j + "," + ai[j1] + ")";
stmt.executeUpdate(s3);
int l = ai[k - 1];
ai[k - 1] = ai[j1];
ai[j1] = l;
k--;
}
j++;
}
}
catch(Exception exception)
{
return 0;
}
return i;
}
}
关于java随机出题源代码和java测试数据随机生成的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读