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;
    }
    }
  • 相关阅读:
    自定义 alert 弹窗
    js控制div内的滚动条的位置
    vue 的 起手式
    d3.js封装文本实现自动换行和旋转平移等功能
    redux
    mui 本地打包
    vue-router 运行机制 及 底层原理
    替代 Navigator 组件
    react-native 创建 ios 项目
    三元运算符
  • 原文地址:https://www.cnblogs.com/blog-wangke/p/14149603.html
Copyright © 2011-2022 走看看