//测试类中
//获取容器
ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
//获取对象
JdbcTemplate jt = ac.getBean("jdbcTemplate",JdbcTemplate.class);
//执行操作
jt.execute("sql语句");
一些基本操作CRUD
保存
jt.update("insert into account(name,money)values(?,?)","eee","33f");
更新
jt.update("update account set name = ?,money = ? where id = ?","test",4567,7);
删除
jt.update("delete from account where id = ?",8);
查询所有
List<Account> list = jt.query("select * from account where money > ?",new BeanPropertyRowMapper<Account>(Account.class),1000f);
查询返回一行一列
Integer count = jt.queryForObject("select count(*) from account where money > ?",Integer.class,1000f);