?? basedao.java~9~
字號:
package com.jbaptech.accp.netbar.server.dao;
import java.sql.*;
public class BaseDAO {
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";
BaseDAO(Connection dbConnection){
this.dbConnection = dbConnection;
}
protected Connection dbConnection;
protected ResultSet res;
protected PreparedStatement pStatement;
protected String strSql;
public Connection getConnction() {
Connection dbConnection = null;
try {
Class.forName(DRIVER_CLASS);
dbConnection = DriverManager.getConnection(DATABASE_URL, DATABASE_USRE,
DATABASE_PASSWORD);
}
catch (Exception e) {
e.printStackTrace();
}
return dbConnection;
}
public void closeConnection() {
try {
if (dbConnection != null && (!dbConnection.isClosed()))
dbConnection.close();
}
catch (SQLException sqlEx) {
sqlEx.printStackTrace();
}
}
/**
* clear the resultset and statement
* @throws SystemException
*/
public void clearDao() {
closeResultSet();
closeStatement();
}
/**
* close the resuletset
*/
protected void closeResultSet() {
try {
if (this.res != null) {
res.close();
res = null;
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
/**
* close the statement
*/
protected void closeStatement() {
try {
if (this.pStatement != null) {
this.pStatement.close();
this.pStatement = null;
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -