package com.test.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import com.test.domain.User;
@Repository
public class UserDaoImpl implements UserDao {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public int insert(User user) {
// TODO Auto-generated method stub
String sql="insert user (userName) values('"+user.getUserName()+"')";
System.out.println("-------------------------:"+sql);
int res=jdbcTemplate.update(sql);
return res;
}
@Override
public User queryById(int userId) {
// TODO Auto-generated method stub
User user=null;
RowMapper <User>rowMapper= new BeanPropertyRowMapper<User>(User.class);
user=jdbcTemplate.queryForObject("select * from user where userId=?", rowMapper,userId);
return user;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SpringBoot三层架构Demo
共33个文件
class:8个
java:8个
properties:4个
5星 · 超过95%的资源 需积分: 50 63 下载量 37 浏览量
2018-08-29
16:05:28
上传
评论 3
收藏 73KB ZIP 举报
温馨提示
本项目下载后,直接在IDE中导入,由于是Maven项目,所以你本地要有Maven环境,要不然下载不了Jar包
资源推荐
资源详情
资源评论
收起资源包目录
testThreeLayerJDBC.zip (33个子文件)
testThreeLayerJDBC
pom.xml 2KB
target
test-classes
com
test
TestThreeLayerJdbcApplicationTests.class 1KB
classes
META-INF
maven
com.test
testThreeLayerJDBC
pom.xml 2KB
pom.properties 246B
MANIFEST.MF 344B
application.properties 183B
com
test
dao
UserDao.class 201B
UserDaoImpl.class 2KB
domain
User.class 928B
contrller
UserController.class 2KB
TestThreeLayerJdbcApplication.class 729B
service
UserService.class 213B
UserServiceImpl.class 869B
mvnw 6KB
.settings
org.eclipse.m2e.core.prefs 97B
org.eclipse.wst.common.project.facet.core.xml 145B
org.eclipse.core.resources.prefs 155B
org.eclipse.jdt.core.prefs 243B
src
test
java
com
test
TestThreeLayerJdbcApplicationTests.java 337B
main
resources
application.properties 183B
templates
static
java
com
test
dao
UserDao.java 168B
UserDaoImpl.java 1024B
domain
User.java 567B
contrller
UserController.java 895B
service
UserServiceImpl.java 489B
UserService.java 226B
TestThreeLayerJdbcApplication.java 324B
.project 1KB
.classpath 993B
.gitignore 268B
.mvn
wrapper
maven-wrapper.jar 46KB
maven-wrapper.properties 110B
mvnw.cmd 5KB
共 33 条
- 1
资源评论
- ziyude2019-05-21给小朋友做样例,很好用
晨缤绽放
- 粉丝: 4
- 资源: 50
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功