⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dboperation.java

📁 基于java的医院门诊管理系统
💻 JAVA
字号:
package crqs.dboperation;

import java.sql.*;

public abstract class DBOperation {

	protected String userName;

	protected String password;

	protected Connection conn;

	protected Statement stmt;

	protected ResultSet result;

	protected DBOperation() {
	}
	
	public String getUserName(){
		return userName;
	}
	
	public void setUserName(String un){
		this.userName=un;
	}
	
	public String getPassword(){
		return password;
	}
	
	public void setPasswd(String p){
		this.password=p;
	}

	protected DBOperation(String un, String pw) {
		this.userName = un;
		this.password = pw;
	}

	public ResultSet getResult() {
		return result;
	}
	
	public abstract boolean setPassword(String old, String newPw) throws SQLException ;

	public synchronized void closeConnection() {
		if (stmt != null)
			try {
				stmt.close();
				stmt = null;
			} catch (SQLException e) {
				e.printStackTrace();
			}
		if (conn != null)
			try {
				conn.close();
				conn = null;
			} catch (SQLException e) {
				e.printStackTrace();
			}
	}

	protected synchronized void executeQuery(String sqlStr) throws SQLException {
		if (conn == null) {
			conn = DBConnection.getConnection();
			stmt = conn.createStatement();
		}
		result = stmt.executeQuery(sqlStr);
	}

	protected synchronized int executeUpdate(String sqlStr) throws SQLException {
		if (conn == null) {
			conn = DBConnection.getConnection();
			stmt = conn.createStatement();
		}
		return stmt.executeUpdate(sqlStr);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -