ApplicationContextapplicationContext=newClassPathXmlApplicationContext("bean.xml"); JdbcTemplatejdbcTemplate= applicationContext.getBean("jdbcTemplate",JdbcTemplate.class); // 保存 jt.update("insert into account(name,money)values(?,?)","eee",3333f); // 更新 jt.update("update account set name=?,money=? where id=?","test",4567,7); // 删除 jt.update("delete from account where id=?",8); // 查询 List<Account> account = jt.query("select * from account where money>?",newBeanPropertyRowMapper<Account>(Account.class),1000f);
createtable test(id int); delimiter // #定义标识符为双斜杠 dropprocedure if exists test; #如果存在test存储过程则删除 createprocedure test() #创建无参存储过程,名称为test begin declare i int; #申明变量 declare id_ int; declare done int; declare cur cursorforselect id from test; declare continue handler fornot found set done =1; open cur; read_loop: loop fetch cur into id_; if done =1then leave read_loop; end if; select id_; end loop; close cur; end // #结束定义语句 call test(); #调用存储过程