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

📄 chateo.java

📁 几个JavaScript范例程序.包括搜索,聊天,上传进度等.
💻 JAVA
字号:
package book.chat.table;

import java.sql.ResultSet;
import java.sql.SQLException;
import book.chat.DbManager;

public class ChatEO {
	protected int chatID;// 代表数据库中chat_id列

	protected String chatName;// 代表数据库中chat_name列

	protected String startTime;// 代表数据库中start_time列

	public ChatEO() {// 无参的构造方法
		this.chatID = -1;
	}

	public ChatEO(int id) {// 有参的构造方法,参数为chat_id
		this.chatID = id;
		if (!FromDb())// 如果有找到该id的chat
			this.chatID = -1;
	}

	public boolean FromDb() {// 从数据库中读出,并更新bean
		int row = -1;
		// 读记录的sql语句
		String sql = "select * from chat where chat_id=" + this.chatID;
		ResultSet rs = DbManager.getResultSet(sql);// 执行sql语句并返回ResultSet
		try {
			rs.last();// 移动到最后一行
			row = rs.getRow();// 得到总记录数
			if (row == 1) {// 如果只查询到一条记录,则代表该记录存在并更新该类的属性
				this.chatID = rs.getInt("CHAT_ID");
				this.chatName = rs.getString("CHAT_NAME");
				this.startTime = rs.getString("START_TIME");
				return true;
			} else
				return false;
		} catch (SQLException e) {
			e.printStackTrace();
			return false;
		} finally {
			try {// 最后关闭ResutltSet,Statement.并释放连接
				if (rs != null)
					rs.close();
				if (rs.getStatement() != null)
					rs.getStatement().close();
				DbManager.releaseConnection();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

	public int getChatID() {
		return chatID;
	}

	public void setChatID(int chatID) {
		this.chatID = chatID;
	}

	public String getChatName() {
		return chatName;
	}

	public void setChatName(String chatName) {
		this.chatName = chatName;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}
}

⌨️ 快捷键说明

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