- package com.dao;
- import java.util.List;
- import com.tool.JDBConnection;
- import java.util.ArrayList;
- import java.sql.ResultSet;
- import java.sql.*;
- import com.domain.CqyxzForm;
- import com.tool.SQLCode;
- public class CqyxzDaoImpl
- implements CqyxzDao {
- //查找的操作
- public List qyxzSelect() {
- JDBConnection connection = null;
- List list = new ArrayList();
- connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qyxz.select");
- CqyxzForm form = null;
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CqyxzForm();
- form.setQyxz_id(rs.getString(1));
- form.setQyxz_xzmc(rs.getString(2));
- form.setQyxz_bz(rs.getString(3));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- //删除的操作
- public void qyxzDelete(CqyxzForm qyxz) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qyxz.delete");
- sql = connection.editSqlCode(sql, qyxz.getQyxz_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //单独查找操作
- public CqyxzForm qyxzSelectOne(CqyxzForm qyxz) {
- JDBConnection connection = null;
- connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qyxz.selectOne");
- sql = connection.editSqlCode(sql, qyxz.getQyxz_id());
- CqyxzForm form = null;
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CqyxzForm();
- form.setQyxz_id(rs.getString(1));
- form.setQyxz_xzmc(rs.getString(2));
- form.setQyxz_bz(rs.getString(3));
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return form;
- }
- //修改的操作
- public void qyxzUpdate(CqyxzForm qyxz) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qyxz.update");
- sql = connection.editSqlCode(sql, qyxz.getQyxz_xzmc());
- sql = connection.editSqlCode(sql, qyxz.getQyxz_bz());
- sql = connection.editSqlCode(sql, qyxz.getQyxz_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //以数据库中的记录数,查找出多少记录计算,以便做帐号存贮
- public int qyxzCount() {
- int iCount = 0;
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qyxz.count");
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- CqyxzForm form = new CqyxzForm();
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount+1;
- }
- //插入的操作
- public void qyxzInsert(CqyxzForm qyxz) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qyxz.insert");
- sql = connection.editSqlCode(sql, qyxz.getQyxz_id());
- sql = connection.editSqlCode(sql, qyxz.getQyxz_xzmc());
- sql = connection.editSqlCode(sql, qyxz.getQyxz_bz());
- connection.executeUpdate(sql);
- connection.close();
- }
- }