zoukankan      html  css  js  c++  java
  • JDBC工具类的提取

    package JDBCUtils;
    
    import java.sql.*;
    
    public class JDBCUtils{
        private static final String driverClass;
        private static final String url;
        private static final String username;
        private static final String password;
    
        static{
            driverClass="com.mysql.jdbc.Driver";
            url="jdbc:mysql:///jdbc?serverTimezone=UTC";
            username="root";
            password="root";
         try{
    loadDriver();
         }catch(ClassNotFoundException e){
           e.printStackTrace();
         }
    }
    public void loadDriver() throws ClassNotFoundException { Class.forName(driverClass); } public static Connection getConnection() throws SQLException { Connection conn = DriverManager.getConnection(url, username, password); return conn; } public static void release(Connection conn, Statement stat) { if (stat != null) { try { stat.close(); } catch (SQLException e) { e.printStackTrace(); } stat = null; } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } conn = null; } } public static void release(ResultSet rs,Connection conn, Statement stat) { if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } rs = null; } if (stat != null) { try { stat.close(); } catch (SQLException e) { e.printStackTrace(); } stat = null; } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } conn = null; } } }
    try {
    loadDriver();
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    }
  • 相关阅读:
    d is undefined错误
    $ is not defined错误类型
    jsonp从服务器读取数据并且予以显示
    jquery来跨域提交表单
    json和jsonp的使用格式
    Compaction介绍
    mysql操作
    DNS安装配置
    FLUSH TABLES WITH READ LOCK 和 LOCK TABLES 之种种
    执行安装redis报错undefined reference to `__sync_add_and_fetch_4'
  • 原文地址:https://www.cnblogs.com/shouyaya/p/12319133.html
Copyright © 2011-2022 走看看