zoukankan      html  css  js  c++  java
  • App(4.23)

    今天依旧是数据库

    public class DBOpenHelper {
        private static String driver = "com.mysql.jdbc.Driver";
        private static String url = "jdbc:mysql://localhost:3306/test?characterEncoding=utf-8";
        private static String user = "root";//用户名
        private static String password = "root";//密码
    
        public static Connection getConn(){
            Connection conn = null;
            try {
                Class.forName(driver);
                conn = (Connection) DriverManager.getConnection(url,user,password);//获取连接
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return conn;
        }
    
        //登录的查询
        public static boolean loginByAccount(String username,String password) {
            Connection conn = getConn();
            String sql = "select *from account where username = ? and password = ? ";
            if (conn != null) {//进行查询是否有该用户
                try {
                    PreparedStatement ps = conn.prepareStatement(sql);
                    ps.setString(1,username);
                    ps.setString(2,password);
    
                    ResultSet rs = ps.executeQuery();
                    if (rs != null) {
                        return true;
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
    
            }
            return false;
        }
    }
  • 相关阅读:
    对象比较
    ObservableCollection<T> 的同类 ListCollectionView
    数据模板--DataTemplate
    ListBox的虚拟可视化技术
    WPF 动画 和 色彩 的随笔
    Binding.RelativeSource 属性
    javascript基础DOM操作
    js dom 操作技巧
    js 内置对象和方法 示例
    javascript 编程技巧
  • 原文地址:https://www.cnblogs.com/ywqtro/p/12764573.html
Copyright © 2011-2022 走看看