首页>代码>Spring Boot学习(七)之Web应用使用JdbcTemplate访问数据库 博客源码分享>/springbootstudy-demo7-jdbctemplate/src/main/java/com/xiaojingg/service/UserServiceImpl.java
package com.xiaojingg.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
 * 筱进GG
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void create(String name, Integer age) {
        jdbcTemplate.update("insert into USER(NAME, AGE) values(?, ?)", name, age);
    }

    @Override
    public void deleteByName(String name) {
        jdbcTemplate.update("delete from USER where NAME = ?", name);
    }

    @Override
    public Integer getAllUsers() {
        return jdbcTemplate.queryForObject("select count(1) from USER", Integer.class);
    }

    @Override
    public void deleteAllUsers() {
        jdbcTemplate.update("delete from USER");
    }
}
最近下载更多
superscro  LV9 2020年5月4日
6615003qq  LV7 2019年10月9日
1jj15j  LV6 2019年8月2日
15088605151@139.com  LV12 2019年4月6日
WangGping  LV2 2019年3月25日
Yimi1919  LV3 2019年3月14日
caozhou  LV14 2019年3月14日
jiangxiaoyu  LV17 2019年2月27日
低调人  LV38 2019年2月23日
slgc2010  LV11 2018年9月11日
最近浏览更多
小赤0120  LV4 2022年12月20日
王乐22222  LV10 2022年5月15日
做自己的太阳  LV11 2021年11月10日
陈fdgd  LV1 2021年11月5日
LL68888 2021年8月3日
暂无贡献等级
水光浮藻  LV6 2021年3月25日
汤汤汤要学编程  LV11 2020年10月19日
哈哈zr  LV11 2020年8月14日
贾老师  LV1 2020年7月2日
lll111  LV16 2020年6月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友