// Path: src/edu/zjut/dao/SecondCategoryDao.java
// public interface SecondCategoryDao {
// 	boolean createSecondCategory(SecondCategory categorySecond) throws SQLException;
// 	boolean updateSecondCategory(SecondCategory categorySecond) throws SQLException;
// 	boolean deleteSecondCategory(int categorySecondId) throws SQLException;
// 	ArrayList<SecondCategory> getAllSecondCategories() throws SQLException;
// 	ArrayList<SecondCategory> getSecondCategoriesByCategoryId(int categoryId) throws SQLException;
// 	int getCategoryIdByName(String categoryName) throws SQLException;
// 	int getSecondCategoryIdByName(String categoryName) throws SQLException;
// }
// 
// Path: src/edu/zjut/model/SecondCategory.java
// public class SecondCategory implements Serializable {
// 	
// 	private static final long serialVersionUID = 1L;
// 	
// 	private int secondCategoryId;
// 	private String secondCategoryName;
// 	private int categoryId;
// 	
// 	public SecondCategory() {
// 	}
// 	
// 	public SecondCategory(int secondCategoryId, String secondCategoryName, int categoryId) {
// 		setSecondCategoryId(secondCategoryId);
// 		setSecondCategoryName(secondCategoryName);
// 		setCategoryId(categoryId);
// 	}
// 
// 	public int getSecondCategoryId() {
// 		return secondCategoryId;
// 	}
// 
// 	public void setSecondCategoryId(int secondCategoryId) {
// 		this.secondCategoryId = secondCategoryId;
// 	}
// 
// 	public String getSecondCategoryName() {
// 		return secondCategoryName;
// 	}
// 
// 	public void setSecondCategoryName(String secondCategoryName) {
// 		this.secondCategoryName = secondCategoryName;
// 	}
// 
// 	public int getCategoryId() {
// 		return categoryId;
// 	}
// 
// 	public void setCategoryId(int categoryId) {
// 		this.categoryId = categoryId;
// 	}
// }
// 
// Path: src/edu/zjut/utils/DBHelp.java
// public class DBHelp {
// 	
// 	private final String DB_DRIVER = "com.mysql.jdbc.Driver";
// 	private final String DB_HOST = "localhost:";
// 	private final String DB_USER = "root";
// 	private final String DB_PASSWORD = "root";
// 	private final String DB_DBNAME = "bookstore";
// 	private final String DB_PORT = "3306/";
// 	private final String DB_URL = "jdbc:mysql://" + DB_HOST + DB_PORT + DB_DBNAME;
// 	public Connection connection = null;
// 	
// 	/**
// 	 * 创建数据库连接
// 	 * @return
// 	 */
// 	public Connection getConn() {
// 		if (connection != null) {
// 			return connection;
// 		}
// 		else {
// 			try {
// 				Class.forName(DB_DRIVER);
// 				connection = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
// 			} catch (ClassNotFoundException | SQLException exception) {
// 				exception.printStackTrace();
// 				return null;
// 			}
// 			return connection;
// 		}
// 	}
// 	
// 	/**
// 	 * 关闭数据库连接
// 	 * @return
// 	 */
// 	public boolean closeConn() {
// 		try {
// 			connection.close();
// 			return true;
// 		} catch (SQLException exception) {
// 			exception.printStackTrace();
// 			return false;
// 		}
// 	}
// }


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import edu.zjut.dao.SecondCategoryDao;
import edu.zjut.model.SecondCategory;
import edu.zjut.utils.DBHelp;
	 * 删除指定二级分类
	 * @param categorySecond
	 * @return
	 * @throws SQLException
	 */
	@Override
	public boolean deleteSecondCategory(int categorySecondId) throws SQLException {
		String sql = "delete form t_category_second where category_second_id = ?";
		pstmt = connection.prepareStatement(sql);
		pstmt.setInt(1, categorySecondId);
		int result = pstmt.executeUpdate();
		if (pstmt != null)
			pstmt.close();
		dbHelp.closeConn();
		return result > 0 ? true : false;
	}
	
	/**
	 * 获取全部二级分类
	 * @param categoryId
	 * @return
	 * @throws SQLException 
	 */
	@Override
	public ArrayList<SecondCategory> getAllSecondCategories() throws SQLException {
		String sql = "select * from t_second_category;";
		pstmt = connection.prepareStatement(sql);
		rs = pstmt.executeQuery();
		ArrayList<SecondCategory> secondCategories = new ArrayList<SecondCategory>();
		while (rs.next()) {
// Path: src/edu/zjut/dao/SecondCategoryDao.java
// public interface SecondCategoryDao {
// 	boolean createSecondCategory(SecondCategory categorySecond) throws SQLException;
// 	boolean updateSecondCategory(SecondCategory categorySecond) throws SQLException;
// 	boolean deleteSecondCategory(int categorySecondId) throws SQLException;
// 	ArrayList<SecondCategory> getAllSecondCategories() throws SQLException;
// 	ArrayList<SecondCategory> getSecondCategoriesByCategoryId(int categoryId) throws SQLException;
// 	int getCategoryIdByName(String categoryName) throws SQLException;
// 	int getSecondCategoryIdByName(String categoryName) throws SQLException;
// }
// 
// Path: src/edu/zjut/model/SecondCategory.java
// public class SecondCategory implements Serializable {
// 	
// 	private static final long serialVersionUID = 1L;
// 	
// 	private int secondCategoryId;
// 	private String secondCategoryName;
// 	private int categoryId;
// 	
// 	public SecondCategory() {
// 	}
// 	
// 	public SecondCategory(int secondCategoryId, String secondCategoryName, int categoryId) {
// 		setSecondCategoryId(secondCategoryId);
// 		setSecondCategoryName(secondCategoryName);
// 		setCategoryId(categoryId);
// 	}
// 
// 	public int getSecondCategoryId() {
// 		return secondCategoryId;
// 	}
// 
// 	public void setSecondCategoryId(int secondCategoryId) {
// 		this.secondCategoryId = secondCategoryId;
// 	}
// 
// 	public String getSecondCategoryName() {
// 		return secondCategoryName;
// 	}
// 
// 	public void setSecondCategoryName(String secondCategoryName) {
// 		this.secondCategoryName = secondCategoryName;
// 	}
// 
// 	public int getCategoryId() {
// 		return categoryId;
// 	}
// 
// 	public void setCategoryId(int categoryId) {
// 		this.categoryId = categoryId;
// 	}
// }
// 
// Path: src/edu/zjut/utils/DBHelp.java
// public class DBHelp {
// 	
// 	private final String DB_DRIVER = "com.mysql.jdbc.Driver";
// 	private final String DB_HOST = "localhost:";
// 	private final String DB_USER = "root";
// 	private final String DB_PASSWORD = "root";
// 	private final String DB_DBNAME = "bookstore";
// 	private final String DB_PORT = "3306/";
// 	private final String DB_URL = "jdbc:mysql://" + DB_HOST + DB_PORT + DB_DBNAME;
// 	public Connection connection = null;
// 	
// 	/**
// 	 * 创建数据库连接
// 	 * @return
// 	 */
// 	public Connection getConn() {
// 		if (connection != null) {
// 			return connection;
// 		}
// 		else {
// 			try {
// 				Class.forName(DB_DRIVER);
// 				connection = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
// 			} catch (ClassNotFoundException | SQLException exception) {
// 				exception.printStackTrace();
// 				return null;
// 			}
// 			return connection;
// 		}
// 	}
// 	
// 	/**
// 	 * 关闭数据库连接
// 	 * @return
// 	 */
// 	public boolean closeConn() {
// 		try {
// 			connection.close();
// 			return true;
// 		} catch (SQLException exception) {
// 			exception.printStackTrace();
// 			return false;
// 		}
// 	}
// }


// Path: src/edu/zjut/dao/impl/SecondCategoryDaoImpl.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import edu.zjut.dao.SecondCategoryDao;
import edu.zjut.model.SecondCategory;
import edu.zjut.utils.DBHelp;

	 * 删除指定二级分类
	 * @param categorySecond
	 * @return
	 * @throws SQLException
	 */
	@Override
	public boolean deleteSecondCategory(int categorySecondId) throws SQLException {
		String sql = "delete form t_category_second where category_second_id = ?";
		pstmt = connection.prepareStatement(sql);
		pstmt.setInt(1, categorySecondId);
		int result = pstmt.executeUpdate();
		if (pstmt != null)
			pstmt.close();
		dbHelp.closeConn();
		return result > 0 ? true : false;
	}
	
	/**
	 * 获取全部二级分类
	 * @param categoryId
	 * @return
	 * @throws SQLException 
	 */
	@Override
	public ArrayList<SecondCategory> getAllSecondCategories() throws SQLException {
		String sql = "select * from t_second_category;";
		pstmt = connection.prepareStatement(sql);
		rs = pstmt.executeQuery();
		ArrayList<SecondCategory> secondCategories = new ArrayList<SecondCategory>();
		while (rs.next()) {
			SecondCategory secondCategory = new SecondCategory();