InsertUser.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:1k
- package com.softeem.webmail.dao.login;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import com.softeem.webmail.dao.DBManager;
- public class InsertUser {
- private Connection conn;
-
- private PreparedStatement ps;
-
- public void insert(String username,String dearname,String password){
- conn = DBManager.getConnection();
- String sql = "insert into user(username,dearname,password) values(?,?,?)";
- try {
- ps = conn.prepareStatement(sql);
- ps.setString(1, username);
- ps.setString(2, dearname);
- ps.setString(3, password);
- ps.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- }finally{
- DBManager.closeConnection(null,ps, conn);
- }
- }
- }