时间:2021-07-01 10:21:17 帮助过:5人阅读
2、操作
@Autowired private JdbcTemplate jdbcTemplate; @Test // 查 public void jdbcTest(){ String sql = "select * from blog"; List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql); System.out.println(maps); } // 插入 @Test public void insertJDBC(){ String sql = "insert into blog(id, title, author, views) values(20, ‘ak‘, ‘tt‘, 100)"; jdbcTemplate.update(sql); } @Test // 修改 public void updateJDBC(){ String sql = "update blog set title = ?, author = ?, views =? where id=" + 20; Object[] objects = new Object[3]; objects[0] = "wt"; objects[1] = "wt"; objects[2] = 100000; jdbcTemplate.update(sql, objects); } @Test // 删除 public void deleteJDBC(){ String sql = "delete from blog where id = ?"; Object[] objects = new Object[1]; objects[0] = 20; jdbcTemplate.update(sql, objects); }
springboot 整合JDBC
标签:temp auth author jdbc end for value insert list