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(); } }
最近下载更多
最近浏览更多
fkjafjkkfo LV2
昨天
lzx602 LV3
4月15日
ruo12138 LV1
4月14日
jiuyin0919 LV1
4月1日
dameir
3月26日
暂无贡献等级
alphaeix
3月18日
暂无贡献等级
微信网友_6906962132258816 LV6
3月16日
WBelong LV7
3月8日
潘潘123456 LV2
3月2日
杨豫川 LV12
1月12日