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

📄 secondleveltitledboperation.java

📁 新闻发布系统
💻 JAVA
字号:
package DBOperation;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import JavaBean.SecondLevelTitle;

public class SecondLevelTitleDbOperation {

	DBConnection db;
	public SecondLevelTitleDbOperation()
	{
		db = new DBConnection("news");
	}

	/**
	 * 添加二级标题
	 */
	public boolean insertSecondLevelTitle(SecondLevelTitle title)
	{
		
		String sql = "insert into SecondLevelTitle values(?,?,?,?,?)";
		try {
			db.getCon();
			db.preSta = db.con.prepareStatement(sql);
			db.preSta.setString(1, title.getTitleName());
			db.preSta.setString(2, title.getFilePath());
			db.preSta.setString(3, title.getCreater());
			db.preSta.setString(4, title.getCreatTime());
			db.preSta.setLong(5, title.getParentTitle());
			return !(db.preSta.execute());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	/**
	 * 按一标题查找所有的二级标题f
	 * @param parentTitleId
	 * @return
	 */
	public ArrayList findSeondLevelTitleOnFirstLevelTitle(int parentTitleId)
	{
		String sql = "select * from SecondLevelTitle where ParentTitle="+parentTitleId;
		ResultSet rs = db.executeQuery(sql);
		ArrayList lst = new ArrayList(); 
		SecondLevelTitle second = null;
		try {
			while(rs.next()) {
				second = new SecondLevelTitle();
				second.setId(rs.getLong("Id"));
				second.setTitleName(rs.getString("Title"));
				second.setFilePath(rs.getString("FilePath"));
				second.setCreater(rs.getString("Creater"));
				second.setCreatTime(rs.getString("CreatTime"));
				second.setParentTitle(rs.getLong("ParentTitle"));
				lst.add(second);
			}
			return lst;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}
	
	public void Close(){
		this.db.Close();
	}

}

⌨️ 快捷键说明

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