📄 xueshenglixiaobean.java
字号:
package xuesheng;
import conn.DataBaseConnection;
import java.sql.Date;
import java.sql.*;
import java.util.*;
import java.io.*;
public class XueshengLixiaoBean
{
private Connection con=null;
public XueshengLixiaoBean()
{
this.con=DataBaseConnection.getConnection();
}
//入录退学的学生
public String addexitXuesheng(XueshengLixiao xueshengLixiao)
{
PreparedStatement pstmt=null;
String str="";
try
{
pstmt=con.prepareStatement("insert into XueshengLixiao values(?,?,?,?,?)");
pstmt.setString(1,xueshengLixiao.getStudentId());
pstmt.setString(2,xueshengLixiao.getLeaveTime());
pstmt.setString(3,xueshengLixiao.getLeaveReason());
pstmt.setString(4,xueshengLixiao.getRemark());
pstmt.setString(5,"3");
pstmt.execute();
str="sucess";
}catch(SQLException ex)
{
System.err.println(ex.getMessage());
str="failer";
}
finally
{
try{
if(pstmt!=null){
pstmt.close();
}
if(con!=null){
con.close();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
return str;
}
//入录休学的学生
public String addrestXuesheng(XueshengLixiao xueshengLixiao)
{
PreparedStatement pstmt=null;
String str="";
try
{
pstmt=con.prepareStatement("insert into XueshengLixiao values(?,?,?,?,?)");
pstmt.setString(1,xueshengLixiao.getStudentId());
pstmt.setString(2,xueshengLixiao.getLeaveTime());
pstmt.setString(3,xueshengLixiao.getLeaveReason());
pstmt.setString(4,xueshengLixiao.getRemark());
pstmt.setString(5,"2");
pstmt.execute();
str="sucess";
}catch(SQLException ex)
{
System.err.println(ex.getMessage());
str="failer";
}
finally
{
try{
if(pstmt!=null){
pstmt.close();
}
if(con!=null){
con.close();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
return str;
}
//入录复学的学生
public String addbackXuesheng(XueshengLixiao xueshengLixiao)
{
PreparedStatement pstmt=null;
String str="";
try
{
pstmt=con.prepareStatement("insert into XueshengLixiao values(?,?,?,?,?)");
pstmt.setString(1,xueshengLixiao.getStudentId());
pstmt.setString(2,xueshengLixiao.getLeaveTime());
pstmt.setString(3,xueshengLixiao.getLeaveReason());
pstmt.setString(4,xueshengLixiao.getRemark());
pstmt.setString(5,"1");
pstmt.execute();
str="sucess";
}catch(SQLException ex)
{
System.err.println(ex.getMessage());
str="failer";
}
finally
{
try{
if(pstmt!=null){
pstmt.close();
}
if(con!=null){
con.close();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
return str;
}
//查询
public ResultSet executeQuery(String sql)
{
Statement stmt=null;
ResultSet rst=null;
try{
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rst=stmt.executeQuery(sql);
}catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
return rst;
}
//关闭
public void close()
{
try{
if(con!=null){
con.close();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -