package com.baobaotao.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Repository;
import com.baobaotao.domain.User;
@Repository
public class UserDao {
@Autowired
private JdbcTemplate jdbcTemplate;
public int getMatchCount(String userName, String password) {
String sqlStr = " SELECT count(*) FROM t_user "
+ " WHERE user_name =? and password=? ";
return jdbcTemplate.queryForInt(sqlStr, new Object[] { userName, password });
}
public User findUserByUserName(final String userName) {
String sqlStr = " SELECT user_id,user_name,credits "
+ " FROM t_user WHERE user_name =? ";
final User user = new User();
jdbcTemplate.query(sqlStr, new Object[] { userName },
new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
user.setUserId(rs.getInt("user_id"));
user.setUserName(userName);
user.setCredits(rs.getInt("credits"));
}
});
return user;
}
public void updateLoginInfo(User user) {
String sqlStr = " UPDATE t_user SET last_visit=?,last_ip=?,credits=? "
+ " WHERE user_id =?";
jdbcTemplate.update(sqlStr, new Object[] { user.getLastVisit(),
user.getLastIp(),user.getCredits(),user.getUserId()});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springmvc-demo.zip (70个子文件)
springmvc-demo
.project 1KB
.settings
.jsdtscope 503B
org.eclipse.wst.common.component 496B
org.eclipse.jdt.core.prefs 395B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
src
log4j.properties 215B
com
baobaotao
dao
LoginLogDao.java 915B
UserDao.java 1KB
domain
LoginLog.java 813B
User.java 1KB
web
LoginController.java 1KB
LoginCommand.java 394B
service
TestUserService.java 1KB
UserService.java 1KB
applicationContext.xml 2KB
sampledb.sql 625B
build
classes
log4j.properties 215B
com
baobaotao
dao
LoginLogDao.class 1KB
UserDao$1.class 1KB
UserDao.class 2KB
domain
User.class 2KB
LoginLog.class 1KB
web
LoginController.class 2KB
LoginCommand.class 753B
service
UserService.class 2KB
TestUserService.class 2KB
applicationContext.xml 2KB
sampledb.sql 625B
WebContent
WEB-INF
baobaotao-servlet.xml 1KB
web.xml 2KB
jsp
login.jsp 550B
main.jsp 455B
lib
commons-logging.jar 59KB
org.springframework.aspects-3.1.2.RELEASE.jar 49KB
commons-pool-1.3.jar 61KB
org.springframework.jdbc-3.1.2.RELEASE.jar 395KB
org.springframework.web.struts-3.1.2.RELEASE.jar 30KB
org.springframework.context.support-3.1.2.RELEASE.jar 105KB
org.springframework.test-3.1.2.RELEASE.jar 224KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
org.springframework.beans-3.1.2.RELEASE.jar 578KB
org.springframework.transaction-3.1.2.RELEASE.jar 239KB
org.springframework.instrument-3.1.2.RELEASE.jar 7KB
org.springframework.expression-3.1.2.RELEASE.jar 172KB
org.springframework.asm-3.1.2.RELEASE.jar 52KB
jstl.jar 17KB
org.springframework.web.portlet-3.1.2.RELEASE.jar 186KB
org.springframework.orm-3.1.2.RELEASE.jar 371KB
org.springframework.aop-3.1.2.RELEASE.jar 325KB
org.springframework.context-3.1.2.RELEASE.jar 813KB
org.springframework.instrument.tomcat-3.1.2.RELEASE.jar 11KB
org.springframework.web-3.1.2.RELEASE.jar 536KB
commons-dbcp-1.2.1.jar 105KB
servlet-api.jar 82KB
org.springframework.spring-library-3.1.2.RELEASE.libd 1KB
junit-4.8.2.jar 232KB
org.springframework.core-3.1.2.RELEASE.jar 439KB
org.springframework.web.servlet-3.1.2.RELEASE.jar 564KB
mysql-connector-java-5.1.7-bin.jar 693KB
org.springframework.jms-3.1.2.RELEASE.jar 194KB
aopalliance-1.0.jar 4KB
org.springframework.oxm-3.1.2.RELEASE.jar 71KB
aspectjweaver.jar 1.57MB
standard.jar 497KB
index.jsp 882B
log4j.properties 214B
META-INF
MANIFEST.MF 39B
.classpath 4KB
共 70 条
- 1
资源评论
- yh9108222014-06-11没法导入运行
- zjw_nm2014-01-01乱码啊,看不懂
- hqs082014-02-28入门的实例,简单易懂
wangchenggong1988
- 粉丝: 77
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- springboot-mavenBaseDemo 内容包含:springboot的maven基础状态,1.8JDK可以直接运行
- otis rsl远程串行接口协议标准.pdf
- buildx构建镜像时所需的镜像文件
- F103-霸道开发板2.8寸电阻触摸屏例程.rar
- Google(高德)地图瓦片python代码下载
- Python实现输出杨辉三角形
- polsarpro官方教程、操作说明 PolSARpro v5.0 Software Training Course
- STM32 TouchGFX的使用二图片显示
- buildx镜像文件,也可以通过网上其他方式获取
- 【中级软件设计师】上午题12-软件工程(2):单元测试、黑盒测试、白盒测试、软件运行与维护
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功