package cn.com.dao;

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 cn.com.entity.Class;
import cn.com.entity.Student;
import cn.com.utils.DBUtils;


public class ClassDao {
	Connection conn;
	PreparedStatement pst;
	ResultSet rs;
	
	
	public List<Class> classByshow(String sid) {
		// TODO Auto-generated method stub
		try {
			conn = DBUtils.getConn();
			String sql = "select * from student s,teacher t,class c where s.cid = c.cid and c.tid = t.tid and s.sid = ?";
			pst = conn.prepareStatement(sql);
			pst.setString(1, sid);
			rs = pst.executeQuery();
			List<Class> bylist = new ArrayList();
			while(rs.next()){
				Class cl = new Class();
				cl.setCid(rs.getInt("cid"));
				cl.setCname(rs.getString("cname"));
				cl.setCqq(rs.getString("cqq"));
				cl.setCxc(rs.getString("cxc"));
				cl.setTid(rs.getString("Tid"));
				cl.setTname(rs.getString("tname"));
				cl.setTphone(rs.getString("tphone"));
				bylist.add(cl);
				System.out.println(bylist+"???");
			}
			return bylist;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtils.closeResouce(conn, pst, rs);
		}
		return null;
	}


	public List<Class> showClass() {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
				try {
					conn = DBUtils.getConn();
					String sql = "select * from class c,teacher t where  t.tid = c.tid";
					pst = conn.prepareStatement(sql);
				
					rs = pst.executeQuery();
					List<Class> bylist = new ArrayList();
					while(rs.next()){
						Class cl = new Class();
						cl.setCid(rs.getInt("cid"));
						cl.setCname(rs.getString("cname"));
						cl.setCqq(rs.getString("cqq"));
						cl.setCxc(rs.getString("cxc"));
						cl.setTid(rs.getString("Tid"));
						cl.setTname(rs.getString("tname"));
						cl.setTphone(rs.getString("tphone"));
						bylist.add(cl);
						System.out.println(bylist+"???+++++++++++++++++++++++");
					}
					return bylist;
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					DBUtils.closeResouce(conn, pst, rs);
				}
				return null;
			
	}

}
最近下载更多
alive13gyp  LV2 3月19日
huangzy  LV12 2024年10月23日
3263394665  LV9 2023年11月29日
你爹正在加载中  LV4 2023年7月12日
全栈小白  LV35 2023年5月23日
ewan007  LV30 2023年2月20日
263648  LV7 2023年2月14日
stonewan  LV10 2022年11月25日
485415187  LV6 2022年11月24日
bluesky2016  LV15 2022年7月6日
最近浏览更多
alive13gyp  LV2 3月19日
LoveSummer  LV6 2024年10月31日
颜菜菜  LV2 2024年9月6日
janeqin  LV1 2024年7月18日
TY0165  LV20 2024年6月24日
胡闹的番茄精  LV2 2024年6月17日
卢旯旯  LV4 2024年6月11日
jimodeai  LV15 2024年5月5日
周青松197  LV3 2024年4月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友