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

📄 buildinginfo.java

📁 JSP移动商品管理平台源代码.........
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -