zoukankan      html  css  js  c++  java
  • 团队冲刺——第五天

    https://www.cnblogs.com/three3/p/12747652.html

    今天写代码数量:package com.example.a15979.shudong;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;

    public class DBUtil
    {
        private  String name=null;
        private  String pass=null;

        public DBUtil(String m,String p){
            this.name=m;
            this.pass=p;
        }
        private static Connection getSQLConnection(String ip, String user, String pwd, String db)
        {
            Connection con = null;
            try
            {
                Class.forName("net.sourceforge.jtds.jdbc.Driver");
                con = DriverManager.getConnection("jdbc:jtds:sqlserver://" + ip + ":3306/" + db + ";charset=utf8", user, pwd);
            } catch (ClassNotFoundException e)
            {
                e.printStackTrace();
            } catch (SQLException e)
            {
                e.printStackTrace();
            }
            return con;
        }

        public String QuerySQL()
        {
            String result = "";
            try
            {
                Connection conn= getSQLConnection("39.97.109.245", "root", "abc456", "TDTreeHole");//根据自己的数据库信息填写对应的值
                String sql = "select username from user  where password=? and  username=? ";
                PreparedStatement stat = conn.prepareStatement(sql);
                stat.setString(1, pass);
                stat.setString(2, name);
                ResultSet rs = stat.executeQuery();
                while (rs.next())
                {
                    result= "1" ;
                }
                rs.close();
                conn.close();
            } catch (SQLException e)
            {
                e.printStackTrace();
                result += "查询数据异常!" + e.getMessage();
            }
            return result;
        }
        public static void main(String[] args)
        {
        }
    }

  • 相关阅读:
    【转】Android系统中Fastboot和Recovery所扮演的角色。
    【转】Android ROM分析(1):刷机原理及方法
    【转】ANDROIDROM制作(一)——ROM结构介绍、精简和内置、一般刷机过程
    【转】使用fastboot命令刷机流程详解
    检测是否安装或者开启flash
    CentOS中/英文环境切换教程(CentOS6.8)
    id: cannot find name for user ID xxx处理办法
    linux重命名所有find查找到的文件/文件夹
    linux过滤旧文件中的空行和注释行剩余内容组成新文件
    CentOS和AIX查看系统序列号
  • 原文地址:https://www.cnblogs.com/hang-hang/p/12747779.html
Copyright © 2011-2022 走看看