📄 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 + -