dbsqlmanager.java

来自「高校毕业生答辩安排管理系统」· Java 代码 · 共 66 行

JAVA
66
字号
package dbxz;

import java.sql.*;
import dbxz.*;

public class DBSQLManager{
	protected Connection conn = null;	//Connection对象
	protected Statement stmt = null;	//Statement对象
	protected ResultSet rs = null;		//记录结果集
	protected String sqlStr;			//SQL语句
	
	public DBSQLManager() {
		try
		{
			sqlStr = "";
			DBConnectionManager dcm = new DBConnectionManager();
			conn = dcm.getConnection();
			stmt = conn.createStatement();
		}
		catch (Exception e) {
			System.out.println(e);
		}
		
	}

	public Statement getStmt() {
		return stmt;
	}

	public Connection getConn() {
		return conn;
	}

	public ResultSet getRs() {
		return rs;
	}

	public void setSqlStr(String newSqlStr) {
		this.sqlStr=newSqlStr;
	}


	public String getSqlStr() {
		return sqlStr;
	}

	public void executeQuery() throws Exception  {
		rs = stmt.executeQuery(sqlStr);
	}

	
	public void executeUpdate() throws Exception  {
		stmt.executeUpdate(sqlStr);
	}
	
	public void close() throws SQLException {
		if ( stmt != null ) {
			stmt.close();
			stmt = null;
		}
		conn.close();
		conn = null;
	}

};

⌨️ 快捷键说明

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