/*******************************************************************************
* $Header$
* $Revision$
* $Date$
*
*==============================================================================
*
* Copyright (c) 2001-2006 Primeton Technologies, Ltd.
* All rights reserved.
*
* Created on 2009-9-10
*******************************************************************************/
package com.richweb.eos;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.eos.system.annotation.Bizlet;
@Bizlet("")
public class PubBuss {
Connection con = null ;
PreparedStatement ps = null ;
StringBuffer sbf = null ;
ResultSet rs = null ;
@Bizlet("")
public void add(Student stu){
con = DataSourceFactory.getConnection() ;
sbf = new StringBuffer() ;
sbf.append("insert into jar_student values(?,?,?)");
try {
ps = con.prepareStatement(sbf.toString()) ;
ps.execute() ;
con.close() ;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Bizlet("")
public List findAllstu(){
List list = new ArrayList();
con = DataSourceFactory.getConnection() ;
sbf = new StringBuffer() ;
sbf.append("select * from jar_student");
try {
ps = con.prepareStatement(sbf.toString());
rs = ps.executeQuery();
while(rs.next()){
Student stu = new Student() ;
stu.setStuid(rs.getInt("STUID"));
stu.setStuage(rs.getInt("STUAGE"));
stu.setStuduc(rs.getString("STUDUC"));
stu.setStugree(rs.getString("STUGREE")) ;
stu.setStuhob(rs.getString("STUHOB"));
stu.setStuname(rs.getString("STUNAME"));
stu.setStusex(rs.getString("STUSEX"));
stu.setSchid(rs.getInt("SCHID"));
list.add(stu);
}
con.close() ;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list ;
}
@Bizlet("")
public List findstubysch(String schid){
List list = new ArrayList();
con = DataSourceFactory.getConnection() ;
sbf = new StringBuffer() ;
sbf.append("select * from jar_student where schid = ").append(schid);
try {
ps = con.prepareStatement(sbf.toString());
rs = ps.executeQuery();
while(rs.next()){
Student stu = new Student() ;
stu.setStuid(rs.getInt("STUID"));
stu.setStuage(rs.getInt("STUAGE"));
stu.setStuduc(rs.getString("STUDUC"));
stu.setStugree(rs.getString("STUGREE")) ;
stu.setStuhob(rs.getString("STUHOB"));
stu.setStuname(rs.getString("STUNAME"));
stu.setStusex(rs.getString("STUSEX"));
stu.setSchid(rs.getInt("SCHID"));
list.add(stu);
}
con.close() ;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list ;
}
@Bizlet("")
public void delete(int pkid){
con = DataSourceFactory.getConnection() ;
sbf = new StringBuffer() ;
sbf.append("delete from jar_student where stuid=").append(pkid);
try {
ps = con.prepareStatement(sbf.toString());
ps.execute() ;
con.close() ;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Bizlet("")
public void mod(Student stu){
};
@Bizlet("")
public List findAllsch(){
List list = new ArrayList();
con = DataSourceFactory.getConnection() ;
sbf = new StringBuffer() ;
sbf.append("select * from jar_school");
try {
ps = con.prepareStatement(sbf.toString());
rs = ps.executeQuery();
while(rs.next()){
School sch = new School() ;
sch.setSchid(rs.getInt("SCHID"));
sch.setSchname(rs.getString("SCHNAME"));
list.add(sch);
}
con.close() ;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list ;
}
public String[] hoby(){
String[] hoby = new String[3] ;
hoby[0] = "游泳";
hoby[1] = "篮球";
hoby[2] = "足球";
return hoby ;
}
}