6.12-PrepareStatement,JdbcUtil 读取数据库配置文件properties,dao模式

时间:2023-03-09 13:33:18
6.12-PrepareStatement,JdbcUtil 读取数据库配置文件properties,dao模式
一、PrepareStatement
防止sql注入
PrepareStatement 是预编译sql语句
更加灵活,更有效率
executeUpdate() 做增删改
executeQuery() 查询
? 占位符
从1开始计数
二、*JdbcUtil 读取数据库配置文件properties
抽取工具类JdbcUtil
获取连接
释放资源
读取配置文件:
类加载器读取配置文件
驱动信息,url,用户名,密码
ResourceBundle 三、dao模式
entity,bean,pojo,domain
dao 数据操作层
daoImpl
service 业务层
serviceImpl
test 测试层(junit4单元测试)
持久化:
将程序中的数据在瞬时状态和
持久状态间转换的机制即为数据持久化
使用面向接口编程降低代码之间的耦合性 四、C3p0连接池配置