⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbutils.java

📁 电子通讯录实现网上保存朋友
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package utils;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Statement;import java.util.logging.Level;import java.util.logging.Logger;/** * * @author Jason */public class DBUtils {    private static final String DRIVER =            "com.mysql.jdbc.Driver";    private static final String URL =            "jdbc:mysql:///eabook";    private static final String USERNAME = "root";    private static final String PWD = "root";    public static Connection getConnection() {        Connection con = null;        try {            Class.forName(DRIVER);            con = DriverManager.getConnection(URL, USERNAME, PWD);        } catch (SQLException ex) {            Logger.getLogger(DBUtils.class.getName()).log(Level.SEVERE, null, ex);        } catch (ClassNotFoundException ex) {            Logger.getLogger(DBUtils.class.getName()).log(Level.SEVERE, null, ex);        }        return con;    }    public static void closeAll(Statement stmt, Connection con) {        try {            if (stmt != null) stmt.close();            if (con != null)  con.close();        } catch (SQLException ex) {            Logger.getLogger(DBUtils.class.getName())                    .log(Level.SEVERE, null, ex);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -