📄 categorydao.java
字号:
package com.sdjs.tree.dao;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import com.sdjs.tree.pojo.Chapter;
import com.sdjs.tree.pojo.Item;
/**
*createTime:2008-10-14 下午04:18:57
*source:http://www.taxchina.com
*file_PATH:com.sdjs.tree.daoCategoryDAO.java
*project_name:AjaxTree
*author:Administrator
*/
public class CategoryDAO extends BaseDAO {
private Chapter mapRow(ResultSet rs) throws SQLException {
Chapter chapter = new Chapter();
chapter.setChapterid(rs.getInt(1));
chapter.setItemid(rs.getInt(2));
chapter.setParentid(rs.getInt(3));
chapter.setChaptername(rs.getString(4));
chapter.setBrief(rs.getString(5));
chapter.setActived(rs.getInt(6)==1?true:false);
chapter.setIsendnode(rs.getInt(7)==1?true:false);
return chapter;
}
public List<Item> getAllItems()throws SQLException
{
String sql = "select * from item";
List<Item> itemList = new ArrayList<Item>();
Statement stmt=this.getConn().createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
Item item = new Item();
item.setItemId(rs.getInt(1));
item.setItemName(rs.getString(2));
itemList.add(item);
System.out.println("--->"+item.getItemName());
}
stmt.close();
return itemList;
}
public List<Chapter> getTopChaptersByItemid(int id)throws SQLException
{
String sql = "select * from chapter where itemid=? and actived=1 and parentid=0 order by orderno ASC";
List<Chapter> cList = new ArrayList<Chapter>();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
ResultSet rs =pstmt.executeQuery();
while(rs.next())
{
Chapter chapter=mapRow(rs);
cList.add(chapter);
}
pstmt.close();
return cList;
}
public List<Chapter> getChaptersByParentid(int id)throws SQLException {
// TODO 自动生成方法存根
String sql = "select * from chapter where parentid=? and actived=1 order by orderno ASC";
List<Chapter> cList = new ArrayList<Chapter>();
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
ResultSet rs =pstmt.executeQuery();
while(rs.next())
{
Chapter chapter=mapRow(rs);
cList.add(chapter);
}
pstmt.close();
return cList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -