📄 databean.java
字号:
{
test4Bean tb = new test4Bean();
tb.setTest_Title(rs.getString("题目").trim());
list.add(tb);
}
}
catch(Exception e)
{
e.printStackTrace();
out.print("数据库连接失败!");
}
return list;
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////存单选题答案/////////////////////////////////////////////////
public void insertTest1(test1Bean tb,String Number,int Num[])
{
db_conn.ConnectDB();
DataBean db=new DataBean();
testBean bean1=db.getnum1();
try
{
String sql=null;
for( int i=0;i<bean1.getN1();i++)
{
sql="update 试卷 set 学生答案='"+tb.getTest_answer()[i]+"' where 准考证号='"+Number+"' and 题型='"+1+"' and 题号="+Num[i];
db_conn.sm.executeUpdate(sql);
}
}
catch (SQLException ex)
{
ex.printStackTrace();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////存多选题答案/////////////////////////////////////////////////
public void insertTest2(test2Bean tb,String Number,int Num[])
{
db_conn.ConnectDB();
DataBean db=new DataBean();
testBean bean2=db.getnum2();
try
{
String sql=null;
for( int i=0;i<bean2.getN2();i++)
{
sql="update 试卷 set 学生答案='"+tb.getTest_answer()[i]+"' where 准考证号='"+Number+"' and 题型='"+2+"' and 题号="+Num[i];
db_conn.sm.executeUpdate(sql);
}
}
catch (SQLException ex)
{
ex.printStackTrace();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////存判断题答案/////////////////////////////////////////////////
public void insertTest3(test3Bean tb,String Number,int Num[])
{
db_conn.ConnectDB();
DataBean db=new DataBean();
testBean bean3=db.getnum3();
try
{
String sql=null;
for( int i=0;i<bean3.getN3();i++)
{
sql="update 试卷 set 学生答案='"+tb.getTest_answer()[i]+"' where 准考证号='"+Number+"' and 题型='"+3+"' and 题号="+Num[i];
db_conn.sm.executeUpdate(sql);
}
}
catch (SQLException ex)
{
ex.printStackTrace();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////存编程题答案/////////////////////////////////////////////////
public void insertTest4(String s,String Number)
{
db_conn.ConnectDB();
try
{
String sql=null;
sql="update 试卷 set 学生答案='"+s+"' where 准考证号='"+Number+"' and 题型='"+4+"'";
db_conn.sm.executeUpdate(sql);
}
catch (SQLException ex)
{
ex.printStackTrace();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////查询成绩/////////////////////////////////////////////////
public testBean selectGrade(String Number,String Name)
{
testBean tb = new testBean();
db_conn.ConnectDB();
try
{
String sql="select * from 学生 where 准考证号='"+Number+"' and 姓名='"+Name+"'";
rs=db_conn.sm.executeQuery(sql);
if(rs.next())
{
tb.setTest_Grade(rs.getFloat("成绩"));
}
}
catch (SQLException SqlE)
{
SqlE.printStackTrace();
}
catch (Exception E)
{
E.printStackTrace();
}
finally
{
// 关闭连接,释放数据库资源:
db_conn.CloseDB();
}
return tb;
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////取单选题数/////////////////////////////////////////////////
public testBean getnum1()
{
db_conn.ConnectDB();
testBean tb = new testBean();
try
{
String sql="select * from 试卷设置 ";
rs=db_conn.sm.executeQuery(sql);
if(rs.next())
{
tb.setN1(rs.getInt("单选题数"));
}
}
catch (SQLException SqlE)
{
SqlE.printStackTrace();
}
catch (Exception E)
{
E.printStackTrace();
}
finally
{
// 关闭连接,释放数据库资源:
db_conn.CloseDB();
}
return tb;
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////取多选题数/////////////////////////////////////////////////
public testBean getnum2()
{
db_conn.ConnectDB();
testBean tb = new testBean();
try
{
String sql="select * from 试卷设置 ";
rs=db_conn.sm.executeQuery(sql);
if(rs.next())
{
tb.setN2(rs.getInt("多选题数"));
}
}
catch (SQLException SqlE)
{
SqlE.printStackTrace();
}
catch (Exception E)
{
E.printStackTrace();
}
finally
{
// 关闭连接,释放数据库资源:
db_conn.CloseDB();
}
return tb;
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////取判断题数/////////////////////////////////////////////////
public testBean getnum3()
{
db_conn.ConnectDB();
testBean tb = new testBean();
try
{
String sql="select * from 试卷设置 ";
rs=db_conn.sm.executeQuery(sql);
if(rs.next())
{
tb.setN3(rs.getInt("判断题数"));
}
}
catch (SQLException SqlE)
{
SqlE.printStackTrace();
}
catch (Exception E)
{
E.printStackTrace();
}
finally
{
//关闭连接,释放数据库资源:
db_conn.CloseDB();
}
return tb;
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////取判断题数/////////////////////////////////////////////////
public testBean getnum4()
{
db_conn.ConnectDB();
testBean tb = new testBean();
try
{
String sql="select * from 试卷设置 ";
rs=db_conn.sm.executeQuery(sql);
if(rs.next())
{
tb.setN3(rs.getInt("编程题数"));
}
}
catch (SQLException SqlE)
{
SqlE.printStackTrace();
}
catch (Exception E)
{
E.printStackTrace();
}
finally
{
//关闭连接,释放数据库资源:
db_conn.CloseDB();
}
return tb;
}
//public static void main(String[] args)
//{
// DataBean bean=new DataBean();
//
// System.out.print(bean.getStuSTime("2005010101"));
//test3Bean tb=new test3Bean();
//String a[] ={"a","a","a","a","a","a","a","b","c","b"};
// int b[]={19,12,10,1,2,3,4,5,6,9};
//tb.setTest_answer(a);
// bean.insertTest3(tb, "2003010101",b);
//for(int i=0;i<10;i++)
//System.out.print(tb.getTest_answer()[i]+" ");
// String b=bean.call_procedure_chouti("2005010101");
// System.out.print(b);
// ArrayList list = bean.getTestList4("2003010120");
// for(int i=0;i<list.size();i++)
// {
// test4Bean bea= (test4Bean)list.get(i);
// System.out.println((i+1)+":" + bea.getTest_Title());
// System.out.println("A:" + bea.getTest_A());
// System.out.println("B:" + bea.getTest_B());
// System.out.println("C:" + bea.getTest_C());
// System.out.println("D:" + bea.getTest_D());
// System.out.println("题号:" + bea.getTest_number());
//}
//testBean bea=bean.selectGrade("2003010101","aaa");
// System.out.println("成绩:" +bea.getTest_Grade());
//testBean b=new testBean();
// b=bean.getnum3();
//bean.insertTest4("d:/test", "2003010120");
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -