📄 dboperation.java
字号:
package hospital.db.dboperation;
import java.sql.*;
import hospital.db.dboperation.*;
import hospital.db.*;
/**
* 抽象类,用以封装子类需要用到的数据库操作对象和方法
*
* 作者:Fido Dido
*/
abstract class DBOperation{
protected Statement stmt;
protected ResultSet rs;
protected ResultSet result;
protected String strSQL;
protected String id;
protected Connection conn;
/**
* 构造器
*
* 参数:
* id-用户ID
*/
protected DBOperation(String id)
throws InvalidUserException{
this.id=id;
this.result=null;
try{
this.checkUser(id);
}
catch(InvalidUserException iue){
throw iue;
}
}
/**
* 返回数据集
*
* 返回值-数据集对象
*/
public ResultSet getResultSet(){
return result;
}
/**
* 用户登录,需要子类实现
*
* 参数:
* password-密码
*
* 返回值-操作结果代码
*/
protected abstract int login(String password);
/**
* 关闭数据库连接
*/
public void closeConnection(){
try{
this.rs.close();
this.stmt.close();
}
catch(SQLException sqle){
Debug.log(Debug.getExceptionMsg(sqle));
}
}
/**
* 查询用户名合法性,需要子类实现
*
* 参数:
* id-用户标识符
*/
protected abstract void checkUser(String id)
throws InvalidUserException;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -