zoukankan      html  css  js  c++  java
  • 12.17-javaweb复习

    复习内容:做了一些练习题复习sql连接关闭


    public class DButils {
    static public Connection connection;
    static public String driver = "com.mysql.cj.jdbc.Driver";
    static public String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC";
    static public String user = "root";
    static public String password = "wang@@ke123";

    static public void Connection_close(Connection connection, PreparedStatement preparedStatement) {
    try {
    if (connection != null)
    connection.close();
    if (preparedStatement != null)
    preparedStatement.close();
    } catch (SQLException throwables) {
    throwables.printStackTrace();
    }
    }

    static public void Connection_close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet) {
    try {
    if (resultSet != null)
    resultSet.close();
    if (preparedStatement != null)
    preparedStatement.close();
    if (connection != null)
    connection.close();
    } catch (SQLException throwables) {
    throwables.printStackTrace();
    }
    }

    static public Connection GetConnnection() throws ClassNotFoundException, SQLException {
    Class.forName(driver);
    connection= DriverManager.getConnection(url,user,password);
    return connection;
    }
    }
  • 相关阅读:
    Unix&Linux下常见的性能分析工具介绍
    理解Load Average做好压力测试
    cron 的配置和说明
    原生js模仿下拉刷新功能
    webpack初步了解
    数组的迭代方法
    webpack4
    反思面向对象
    C和lua的互相调用
    对Zookeeper的一些分析
  • 原文地址:https://www.cnblogs.com/blog-wangke/p/14149603.html
Copyright © 2011-2022 走看看