📄 accountscorebean.java
字号:
package javaBeanClass;
import java.sql.*;
import java.util.*;
import javaBeanClass.DatabaseConn;
public class AccountScoreBean{
private int stuID ;
private int testIndexID ;
private String stuAnswers=null ;
private DatabaseConn db=null;
public int getStuID(){
return stuID;
}
public void setStuID(int stuID){
this.stuID=stuID;
System.out.println (stuID);
}
public int getTestIndexID(){
return testIndexID;
}
public void setTestIndexID(int testIndexID){
this.testIndexID=testIndexID;
System.out.println (testIndexID);
}
public String getStuAnswers(){
return this.stuAnswers;
}
public void setStuAnswers(String stuAnswers){
this.stuAnswers=stuAnswers;
System.out.println (stuAnswers);
}
public int accountScore()throws SQLException{
Connection con;
CallableStatement ps=null;
ResultSet rs=null;
try{
db=new DatabaseConn();
con=db.connectToDB();
}
catch(Exception ex){throw new SQLException("Connect database failed!"+ex.getMessage());}
try
{
ps=con.prepareCall("{?=call pr_accountScore(?,?,?)}");
ps.registerOutParameter(1,java.sql.Types.INTEGER);
ps.setInt(2,this.stuID);
ps.setString(3,this.stuAnswers);
ps.setInt(4,this.testIndexID);
ps.executeUpdate();
int returnValue=ps.getInt(1);
if(returnValue==-1){
throw new SQLException("试卷处于非激活状态不能交卷!");
}
if(returnValue==-2){
throw new SQLException("答案生成有误!");
}
if(returnValue==-3){
throw new SQLException("你已经交卷,不能重复交卷!");
}
System.out.println("交卷执行一次!");
return returnValue;
}
catch(Exception ex)
{
System.out.println("FindAll Test failed:"+ex.getMessage());
throw new SQLException(ex.getMessage());
}
finally
{
try{con.close();ps.close();}
catch(SQLException sqlex){System.out.println("FindAll Close Test Error:"+sqlex.getMessage());}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -