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;
    }
    }
  • 相关阅读:
    WordCount的程序设计没写出来怎么办
    小程序分析
    程序单元测试
    Visual studio 2013安装
    四则运算源代码
    在VC环境下执行代码出现错误
    微点评微信软件
    软件工程学习
    查找抄袭文章
    软件附加题简答
  • 原文地址:https://www.cnblogs.com/blog-wangke/p/14149603.html
Copyright © 2011-2022 走看看