⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databaseoptor.java~9~

📁 一个JSPServerlet编写的
💻 JAVA~9~
字号:
package regetemail;

import java.sql.Connection;
import java.sql.SQLException;

public class DataBaseOptor {
    private Connection conn;
    private String userPassword;
    public DataBaseOptor() {

    }

    private Connection getConn() {
        boolean flag = false;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch (ClassNotFoundException ex) {
            System.out.println("建立驱动异常:" + ex.getMessage());
        }
        try {
            conn = java.sql.DriverManager.getConnection("jdbc:odbc:accp", "sa",
                    "");
        } catch (SQLException ex) {
            System.out.println("数据库连接异常");
        }
        return conn;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public boolean getUser(String uname, String upwd) {
        boolean flag = false;
        try {
            Connection con = this.getConn();
            java.sql.Statement stm = con.createStatement();
            java.sql.ResultSet rs = stm.executeQuery(
                    "select * from userInfo where userName='"+uname+"' and userPassword='"+upwd+"'");
            if(rs.next()){
                flag = true;
            }
        } catch (SQLException ex) {
            System.out.println("验证用户密码异常:" + ex.getMessage());
        }
        return flag;
    }
    public boolean userPwdonEmail(String uname, String email) {
       boolean flag = false;
       try {
           Connection con = this.getConn();
           java.sql.Statement stm = con.createStatement();
           java.sql.ResultSet rs = stm.executeQuery(
                   "select * from userInfo where userName='"+uname+"' and userPassword='"+email+"'");
           if(rs.next()){
               this.userPassword = rs.getString(1);
               flag = true;
           }
       } catch (SQLException ex) {
           System.out.println("验证用户密码异常:" + ex.getMessage());
       }
       return flag;
   }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -