buildinginfo.java

来自「JSP移动商品管理平台源代码.........」· Java 代码 · 共 122 行

JAVA
122
字号
package imis_hous.com.util;

import java.util.List;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import database.DBPoolManager;

public class BuildingInfo implements Serializable{

	public BuildingInfo() {
		// TODO Auto-generated constructor stub
	}
	public String getDepartment(String BuildingNu) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select BuildingName from Buildings_info where BuildingNu = '" + BuildingNu+"'";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString(1);
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}
	
	public String getDepartmentBnu(String BuildingNu) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select roomnu from room_info r where r.buildingnu='" + BuildingNu+"'";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString("roomnu");
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}
	public String getDepartmentBname(String BuildingNu) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select BuildingName from Buildings_info where BuildingNu in (select  BuildingNu from Room_Info where RoomNu = '"+BuildingNu+"')";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString("buildingname");
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}
	public String getnewDepartmentBname(String BuildingNu) {
		String res=null;
		ResultSet rs = null;
		Statement stmt = null;
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		String sql = "select b.buildingname from Buildings_info b where b.buildingnu = '"+BuildingNu+"'";
		try {
			stmt = dbpool.conn.createStatement();
			rs = stmt.executeQuery(sql);
			
			while (rs.next()) {
				res = rs.getString("buildingname");
			}
			rs.close();
			stmt.close();
		} catch (SQLException ex) {
			ex.printStackTrace();
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}
	public String getDepartmentBname1(String BuildingNu) {
		String res = "";
		DBPoolManager dbpool = new DBPoolManager();
		dbpool.getConnection();
		try {
			String sql = "select * from buildings_info b where b.buildingnu ='"+BuildingNu+"')";
			Statement selectStatement = dbpool.conn.createStatement();
			ResultSet rest = selectStatement.executeQuery(sql);
			if (rest.next()) {
				res = rest.getString("buildingname");
			}
			rest.close();
			selectStatement.close();
		} catch (SQLException ex) {
			
		} finally {
			dbpool.freeConnection();
		}
		return res;
	}

}

⌨️ 快捷键说明

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