?? connectionmanager.java~2~
字號:
package com.jbaptech.accp.netbar.server.dao;
import java.sql.*;
public class ConnectionManager {
private static final String DRIVER_CLASS =
"sun.jdbc.odbc.JdbcOdbcDriver";
private static final String DATASOURCE = "jdbc:odbc:NetBarDataSource";
// private static final String DRIVER_CLASS =
// "com.microsoft.jdbc.sqlserver.SQLServerDriver";
private static final String DATABASE_URL =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=NetBar";
private static final String DATABASE_USRE = "sa";
private static final String DATABASE_PASSWORD = "sa";
public static Connection getConnction() {
Connection dbConnection = null;
try {
Class.forName(DRIVER_CLASS);
// dbConnection = DriverManager.getConnection(DATABASE_URL, DATABASE_USRE,
// DATABASE_PASSWORD);
dbConnection = DriverManager.getConnection(DATASOURCE);
}
catch (Exception e) {
e.printStackTrace();
}
return dbConnection;
}
public static void closeConnection(Connection dbConnection) {
try {
if (dbConnection != null && (!dbConnection.isClosed()))
dbConnection.close();
}
catch (SQLException sqlEx) {
sqlEx.printStackTrace();
}
}
/**
* close the resuletset
*/
public static void closeResultSet(ResultSet res) {
try {
if (res != null) {
res.close();
res = null;
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
/**
* close the statement
*/
public void closeStatement(PreparedStatement pStatement) {
try {
if (pStatement != null) {
pStatement.close();
pStatement = null;
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -