zoukankan      html  css  js  c++  java
  • 今日总结

    今天的内容:

    学习了Java中对数据库的链接:

    需要导包:mysql-connector-java-5.1.39-bin.jar

    链接方式:

    package DButil;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    public class GetConnect {
        private Connection conn = null;
        private String driver = "com.mysql.jdbc.Driver";
        private String url = "jdbc:mysql://localhost:3306/people?useUnicode=true"
                + "&serverTimezone=UTC&characterEncoding=utf8&" + "useSSL=false&allowPublicKeyRetrieval=true";
        private String user = "root";
        private String passwd = "passwd";
    
        public static void main(String[] args) {
            GetConnect gc = new GetConnect();
            gc.GetConn();
        }
    
        @SuppressWarnings("finally")
        public Connection GetConn() {
            try {
                Class.forName(driver);
                conn = DriverManager.getConnection(url, user, passwd);
                if (!conn.isClosed()) {
                    System.out.println("连接成功");
                }
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } finally {
                return conn;
            }
        }
    }

    问题:无

    明天的打算:继续学习JavaWeb内容

  • 相关阅读:
    Python闭包相关问题
    Python对象引用问题总结
    Django学习记录
    使用Python访问HDFS
    json模块使用总结——Python
    node-redis使用记录
    nodejs学习笔记(2)
    关于mongodb的mapReduce
    nodejs学习笔记
    关于Python的多重排序
  • 原文地址:https://www.cnblogs.com/MXming/p/14162987.html
Copyright © 2011-2022 走看看