📄 xueshengsuzhituozhanbean.java
字号:
package suzhiTuoZhan;
import conn.DataBaseConnection;
import java.sql.*;
import java.util.*;
import java.io.*;
public class XueshengSuzhiTuoZhanBean
{
private Connection con=null;
public XueshengSuzhiTuoZhanBean()
{
this.con=DataBaseConnection.getConnection();
}
//操行评定分类
public Collection getSuzhiTuoZhanFenLei()throws Exception
{
Statement stmt=null;
ResultSet rst=null;
Collection collet=null;
try{
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rst=stmt.executeQuery("select * from suzhiTuoZhanFenLei");
collet=new ArrayList();
while(rst.next())
{
SuzhiTuoZhanFenLei suzhiTuoZhanFenLei=new SuzhiTuoZhanFenLei();
suzhiTuoZhanFenLei.setSortId(rst.getString("sortId"));
suzhiTuoZhanFenLei.setSortName(rst.getString("sortName"));
collet.add(suzhiTuoZhanFenLei);
}
}catch (SQLException ex) {
ex.printStackTrace();
}
return collet;
}
//获得学年
public String getXueNian(String studentId)
{
PreparedStatement pstmt = null;
ResultSet rst = null;
StringBuffer sBuf=new StringBuffer();
try {
pstmt = con.prepareStatement("select grade from banji where classId=(select stuClass from xuesheng where studentId='"+studentId+"')");
rst = pstmt.executeQuery();
if(rst.next()) {
int grade= Integer.parseInt(new String(rst.getString("grade")).trim());
sBuf.append("<option value='"+grade+"'>第一学年</option>\n");
sBuf.append("<option value='"+(grade+1)+"'>第二学年</option>\n");
sBuf.append("<option value='"+(grade+2)+"'>第三学年</option>\n");
sBuf.append("<option value='"+(grade+3)+"'>第四学年</option>\n");
}
}
catch (SQLException ex) {
ex.printStackTrace();
return "";
}
return sBuf.toString();
}
//更新
public void executeUpdate(String sql)
{
Statement stmt=null;
try{
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt.executeUpdate(sql);
}catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
}
//查询
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();
}
}
/*
public static void main(String[] args)throws Exception{
XueshengCaoXingZiPingBean test=new XueshengCaoXingZiPingBean();
//String str=test.getXueNian("0368110051");
//System.out.println(str);
Collection collet=test.getCaoXingFenLei();
Iterator it=collet.iterator();
while(it.hasNext())
{
CaoxingFenLei caoxingFenLei=(CaoxingFenLei)it.next();
String sortId=caoxingFenLei.getSortId();
String sortName=caoxingFenLei.getSortName();
System.out.print(sortId);
System.out.println(sortName);
}
java.util.Date test=new java.util.Date();
int year=test.getYear();
System.out.println(year+1900);
} */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -