Spring中封装好的工具类叫作模板(Template)
导入的坐标为:
快速入门:org.springframework spring-jdbc 5.2.0.RELEASE org.springframework spring-tx 5.2.0.RELEASE
变为:
public class JdbcDemo {
@Test
public void fun(){
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
int i = jdbcTemplate.update("insert into jdbc values (?,?)", 123, "张佳成");
System.out.println(i);
}
}
然后可以抽取Properties工具类,前面都讲过
插入/修改/删除操作
在JdbcTemplate中插入操作/修改操作/删除操作。都归结为update操作。
- 查询所有
- 查询一个



