📄 connectdbutil.java
字号:
package me.work.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public final class ConnectDBUtil {
/**
* this method provides a connection to DB
*
* @throws ClassNotFoundException
* when cannot load jdbcodbcdriver
* @throws SQLException
*/
public static final Connection getConnection()
throws ClassNotFoundException, SQLException {
// load the JdbcOdbcDriver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// get a connection
return DriverManager.getConnection("jdbc:odbc:forum", "sa", "");
}
/**
* close sql connection
*
* @param con
* connection to close
* @throws SQLException
*/
public static final void closeConnection(Connection con)
throws SQLException {
if (con != null) {
con.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -