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

📄 forumbbs.java

📁 用于JSP1.0 开发的一个类似于动网的BBS论坛。 数据库是DB2+JSP+javaBean
💻 JAVA
字号:
package chapter10;

import java.util.Vector;
import java.sql.*;
import chapter10.DateItem;
import chapter10.ConnPool;

public class  ForumBbs
{
 private String sql="";
 private Connection con = null;
 private DateItem item;
 private static ConnPool pool=new ConnPool();

 public synchronized Statement getStateMent()throws Exception
 {
  try{
	  if (pool.getDriver()==null){
		  	pool.setDriver("COM.ibm.db2.jdbc.net.DB2Driver");
		    pool.setURL("jdbc:db2://192.168.1.129/BBS");
			pool.setUsername("ycg");
			pool.setPassword("sntasve");
		    pool.setSize(55);
		    pool.initializePool();
		   }
	  con = pool.getConnection();
	  Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
      return stmt;
	 }catch(Exception e){
		 System.out.println(e.getMessage());
	     return null;
	 }
 }

  public  Vector getDateItem(){

      Vector forumVector=new Vector();

	  try{
		  
		 Statement stmt=this.getStateMent();
		 ResultSet  rs=null;
		 sql="SELECT * FROM Board WHERE pareid=0";
		 rs=stmt.executeQuery(sql);

		 while (rs.next())
		  {  
			 item=new DateItem();
			 item.setForum_id(rs.getString("Boardid"));
		     item.setBoardType(rs.getString("BoardType"));
			 forumVector.add(item);
			 item=null;
			
		  }
		  rs.close();
	      pool.releaseConnection(con);
		  return  forumVector;
     }catch (Exception e){
    	System.out.println(e.getMessage());
	    return null;
  } 
}

  public  Vector getDateItem2(String Forum_id1){

      Vector forumVector2=new Vector();

	  try{
		   
		 Statement stmt=this.getStateMent();
		 ResultSet  rs=null;

		 sql="SELECT * FROM Board WHERE pareid="+Forum_id1;
		 rs=stmt.executeQuery(sql);

		 while (rs.next())
		  {	 
			 item=new DateItem();
			 item.setForum_id(rs.getString("Boardid"));
		     item.setBoardType(rs.getString("BoardType"));
			 forumVector2.add(item);
			
		  }
		  rs.close();
	      pool.releaseConnection(con);
		  return  forumVector2;
     }catch (Exception e){
    	System.out.println(e.getMessage());
	    return null;
  } 
}

public String getDataBaseName(){
	 String dataBaseName=new String();

	try{
		   
		 Statement stmt=this.getStateMent();
		 ResultSet  rs=null;

		 sql="SELECT BASENAME FROM BASE";
		 rs=stmt.executeQuery(sql);
		 if (rs.next())
		 {
			 dataBaseName=rs.getString("BASENAME");
		 }	
	     rs.close();
	     pool.releaseConnection(con);
		 return  dataBaseName;
     }catch (Exception e){
    	System.out.println(e.getMessage());
	    return null;
  } 

}

}

⌨️ 快捷键说明

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