栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

com.gw.bookstroe.dao.impl(Userdaoimpl接口interface)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

com.gw.bookstroe.dao.impl(Userdaoimpl接口interface)

package com.gw.bookstroe.dao.impl;

import java.sql.SQLException;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import com.gw.bookstroe.dao.Userdao;
import com.gw.bookstroe.domain.User;
import com.gw.bookstroe.utils.C3P0Utils;

public class Userdaoimpl implements Userdao {
    QueryRunner runner = new QueryRunner(C3P0Utils.getDataSource());
    @Override
    public User findUser(String username, String password) {
        
        String sql="SElECt * from user where username=? and  password=?";
        
        User user =null;
        try{
            user =(User)runner.query(sql, new BeanHandler(User.class),username,password);
        }catch(SQLException e){
            e.printStackTrace();
        }
        
        return user;
    }
    @Override
    public boolean insert(User user) {
        String sql="insert into user(username,password,gender,email,telephone,introduce,activeCode) values(?,?,?,?,?,?,?)";
        int num =0;
        try {
            num = runner.update(sql, user.getUsername(),user.getPassword()
                    ,user.getGender(),user.getEmail(),user.getTelephone(),user.getIntroduce()
                    ,user.getActiveCode());
            
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if(num>0){return true;}
        return false;
    }
    @Override
    public User findname(String username) {
        String sql="SElECT * from user where username=?";
        
        User user =null;
        try{
            user =(User)runner.query(sql, new BeanHandler(User.class),username);
        }catch(SQLException e){
            e.printStackTrace();
        }
        
        return user;
    }
    @Override
    public boolean editUser(String username, String repassword, String telephone, String email) {
        String sql="update user set PASSWORD=? , telephone=? ,email=? where username=?";
        int num =0;
        try {
            num = runner.update(sql,repassword,telephone,email,username);
            
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if(num>0){return true;}
        return false;
        
    }
    
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/972240.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号