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

📄 topicbean.java

📁 java edit you can use it,thanks
💻 JAVA
字号:
package com.jspdev.business;

import java.util.*;
import com.jspdev.util.*;
import java.sql.*;
import com.jspdev.vo.*;

/**
 *主要用于执行和topic相关的数据库业务逻辑
 */
public class TopicBean extends BaseBean
{
	public TopicBean()throws Exception
	{
		super();
	}
	
	/**
	 *获得指定topicId的topic的信息
	 */
	public TopicVO getTopic(String topicId)throws Exception
	{
		if(con.isClosed()) con=DatabaseConn.getConnection();
		Statement stmt=con.createStatement();
		ResultSet rst=stmt.executeQuery("select * from Topic where id='"+topicId+"'");
		TopicVO top=new TopicVO();
		if(rst.next())
		{
			top.setId(rst.getString("id"));
			top.setTitle(rst.getString("title"));
			top.setContent(rst.getString("content"));
			top.setEmail(rst.getString("email"));
			top.setAuthor(rst.getString("author"));
			top.setPubTime(rst.getDate("pubtime"));
		}
		rst.close();
		con.close();

		return top;
	}
	
	/**
	 *获得指定topicId的reply的信息
	 */
	public TopicVO getReply(String replyId)throws Exception
	{
		if(con.isClosed()) con=DatabaseConn.getConnection();
		Statement stmt=con.createStatement();
		ResultSet rst=stmt.executeQuery("select * from reply where id='"+replyId+"'");
		TopicVO top=new TopicVO();
		if(rst.next())
		{
			top.setId(rst.getString("id"));
			top.setTopicId(rst.getString("topicId"));
			top.setTitle(rst.getString("title"));
			top.setContent(rst.getString("content"));
			top.setEmail(rst.getString("email"));
			top.setAuthor(rst.getString("author"));
			top.setPubTime(rst.getDate("pubtime"));
		}
		rst.close();
		con.close();
		return top;
	}
	
	/**
	 *获得指定topicid的topic的所有回复的信息
	 */
	public Collection getReplys(String topicId)throws Exception
	{
		if(con.isClosed()) con=DatabaseConn.getConnection();
		Statement stmt=con.createStatement();
		ResultSet rst=stmt.executeQuery("select * from reply where topicId='"+topicId+"'");
		Collection ret=new ArrayList();
		while(rst.next())
		{
			TopicVO top=new TopicVO();
			top.setId(rst.getString("id"));
			top.setTopicId(rst.getString("topicId"));
			top.setTitle(rst.getString("title"));
			top.setContent(rst.getString("content"));
			top.setEmail(rst.getString("email"));
			top.setAuthor(rst.getString("author"));
			top.setPubTime(rst.getDate("pubtime"));
			ret.add(top);
		}
		rst.close();
		stmt.close();
		con.close();

		return ret;
	}
		
}

⌨️ 快捷键说明

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