- package com.dao;
- import java.util.List;
- import java.util.ArrayList;
- import com.tool.JDBConnection;
- import com.tool.SQLCode;
- import java.sql.ResultSet;
- import java.sql.*;
- import com.domain.CqylxForm;
- //对表tb_Client_qylx的操作
- public class CqylxDaoImpl
- implements CqylxDao {
- //查询的操作
- public List qylxSelect() {
- JDBConnection connection = new JDBConnection();
- CqylxForm form = null;
- List list = new ArrayList();
- String sql = SQLCode.getSQLCode("sql.qylx.select");
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CqylxForm();
- form.setQylx_id(rs.getString(1));
- form.setQylx_lxmc(rs.getString(2));
- form.setQylx_bz(rs.getString(3));
- list.add(form);
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return list;
- }
- //删除操作
- public void qylxDelete(CqylxForm qylx) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qylx.delete");
- sql = connection.editSqlCode(sql, qylx.getQylx_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //修改操作
- public void qylxupdate(CqylxForm qylx) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qylx.update");
- sql = connection.editSqlCode(sql, qylx.getQylx_lxmc());
- sql = connection.editSqlCode(sql, qylx.getQylx_bz());
- sql = connection.editSqlCode(sql, qylx.getQylx_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //单独查找
- public CqylxForm qylxSelectOne(CqylxForm qylx) {
- JDBConnection connection = new JDBConnection();
- CqylxForm form = null;
- List list = new ArrayList();
- String sql = SQLCode.getSQLCode("sql.qylx.selectOne");
- sql = connection.editSqlCode(sql, qylx.getQylx_id());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- form = new CqylxForm();
- form.setQylx_id(rs.getString(1));
- form.setQylx_lxmc(rs.getString(2));
- form.setQylx_bz(rs.getString(3));
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return form;
- }
- //插入操作
- public void qylxInsert(CqylxForm qylx) {
- JDBConnection connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qylx.insert");
- sql = connection.editSqlCode(sql, qylx.getQylx_id());
- sql = connection.editSqlCode(sql, qylx.getQylx_lxmc());
- sql = connection.editSqlCode(sql, qylx.getQylx_bz());
- connection.executeUpdate(sql);
- connection.close();
- }
- //以数据库中的记录数,查找出多少记录计算,以便做帐号存贮
- public int qulxCount() {
- int iCount = 0;
- JDBConnection connection = null;
- connection = new JDBConnection();
- String sql = SQLCode.getSQLCode("sql.qylx.count");
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- CqylxForm form = new CqylxForm();
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount+1;
- }
- }