首页>代码>java web学生信息管理系统 >/StudentManagerWeb/src/com/ischoolbar/programmer/dao/BaseDao.java
package com.ischoolbar.programmer.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 com.ischoolbar.programmer.util.DbUtil;

/**
 * 
 * @author llq
 *基础dao,封装基本操作
 */
public class BaseDao {
	private DbUtil dbUtil = new DbUtil();
	
	/**
	 * 关闭数据库连接,释放资源
	 */
	public void closeCon(){
		dbUtil.closeCon();
	}
	
	/**
	 * 基础查询,多条查询
	 */
	public ResultSet query(String sql){
		try {
			PreparedStatement prepareStatement = dbUtil.getConnection().prepareStatement(sql);
			return prepareStatement.executeQuery();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	} 
	/**
	 *改变数据库内容操作
	 */
	public boolean update(String sql){
		try {
			return dbUtil.getConnection().prepareStatement(sql).executeUpdate() > 0;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	public Connection getConnection(){
		return dbUtil.getConnection();
	}
}
最近下载更多
李清清  LV2 2024年11月6日
lxm2440226414  LV2 2024年6月10日
云着殇  LV9 2024年6月5日
lzx602  LV3 2024年4月15日
微信网友_6906962132258816  LV7 2024年3月16日
zhangjilu  LV18 2024年1月1日
磊哥哥哥哥  LV13 2023年12月26日
heweimin  LV13 2023年12月12日
hapilong  LV6 2023年12月11日
蹇金金  LV7 2023年10月31日
最近浏览更多
xianyu091012  LV5 2024年12月26日
言123456 2024年12月24日
暂无贡献等级
3375276400 2024年12月24日
暂无贡献等级
TTThai  LV1 2024年12月17日
微信网友_7298641941385216 2024年12月16日
暂无贡献等级
Daima000  LV4 2024年12月5日
李清清  LV2 2024年11月6日
送你一张  LV1 2024年10月28日
krispeng  LV14 2024年9月10日
nurxshat_outl 2024年7月3日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友