2023年6月21日发(作者:)
SpringNamedParameterJdbcTemplate完成数据的增删改查1、Spring配置⽂件 xmlns:p="/schema/p" xmlns:xsi="/2001/XMLSchema-instance" xmlns:aop="/schema/aop" xmlns:context="/schema/context" xmlns:jdbc="/schema/jdbc" xmlns:tx="/schema/tx" xmlns:jpa="/schema/data/jpa" xsi:schemaLocation=" /schema/beans /schema/beans/ /schema/aop /schema/aop/ /schema/context /schema/context/ /schema/jdbc /schema/jdbc/ /schema/tx /schema/tx/ /schema/data/jpa /schema/data/jpa/" default-lazy-init="true">
@Resource private NamedParameterJdbcTemplate jdbcTemplate; //插⼊数据的sql private static final String ADD_SQL="insert into tbl_c3p0(name,address,age) values(:name,:address,:age)"; //根据id获取user对象 private static final String QUERY_SQL="select id,name,address,age from tbl_c3p0 where id=:id"; //修改user对象 private static final String UPDATE_SQL="update tbl_c3p0 set name=:name,address=:address,age=:age where id=:id"; //根据id删除user对象 private static final String DELETE_SQL="delete from tbl_c3p0 where id=:id"; /** * 插⼊数据 */ public void add(User user){ Map
2023年6月21日发(作者:)
SpringNamedParameterJdbcTemplate完成数据的增删改查1、Spring配置⽂件 xmlns:p="/schema/p" xmlns:xsi="/2001/XMLSchema-instance" xmlns:aop="/schema/aop" xmlns:context="/schema/context" xmlns:jdbc="/schema/jdbc" xmlns:tx="/schema/tx" xmlns:jpa="/schema/data/jpa" xsi:schemaLocation=" /schema/beans /schema/beans/ /schema/aop /schema/aop/ /schema/context /schema/context/ /schema/jdbc /schema/jdbc/ /schema/tx /schema/tx/ /schema/data/jpa /schema/data/jpa/" default-lazy-init="true">
@Resource private NamedParameterJdbcTemplate jdbcTemplate; //插⼊数据的sql private static final String ADD_SQL="insert into tbl_c3p0(name,address,age) values(:name,:address,:age)"; //根据id获取user对象 private static final String QUERY_SQL="select id,name,address,age from tbl_c3p0 where id=:id"; //修改user对象 private static final String UPDATE_SQL="update tbl_c3p0 set name=:name,address=:address,age=:age where id=:id"; //根据id删除user对象 private static final String DELETE_SQL="delete from tbl_c3p0 where id=:id"; /** * 插⼊数据 */ public void add(User user){ Map
发布评论