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

📄 zaixiandiaochadaoimpl.java~1~

📁 用JSP制作的个人网站
💻 JAVA~1~
字号:
package liangjuyan.dao;

import liangjuyan.zaixiandiaocha;
import liangjuyan.conndb;
import java.util.List;
import java.util.ArrayList;
import java.sql.ResultSet;
import java.sql.*;
import liangjuyan.chStr;

public class zaixiandiaochadaoimpl
    implements zaixiandiaochadao{
  private conndb conn = new conndb();
  //执行插入操作
  public int insert(zaixiandiaocha z) {
    chStr chStr = new chStr();
    int ret = -1;
    try {
      String sql = "Insert into zaixiandiaocha(Username,Maiguodongxi,Pingjia,Qubie,Gaijin,Fabuxinxi,Zmzd,Tjpy) values('" +
          chStr.chStr(z.getUsername()) + "','" + chStr.chStr(z.getMaiguodongxi()) +
          "','" + chStr.chStr(z.getPingjia()) +"','" + chStr.chStr(z.getQubie()) + "','" + chStr.chStr(z.getGaijin()) +
          "','" + chStr.chStr(z.getFabuxinxi()) + "','" +
          chStr.chStr(z.getZmzd()) + "','" + chStr.chStr(z.getTjpy()) +
          "')";
       ret = conn.executeUpdate(sql);
    }
    catch (Exception e) {
      ret = 0;
    }
    conn.close();
    return ret;
  }

  //执行修改操作
  public int update(zaixiandiaocha z) {
    int ret = -1;
    chStr chStr = new chStr();
    try {
      String sql = "update zaixiandiaocha set username='" +
          chStr.chStr(z.getUsername()) +
          "',maiguodongxi='" + chStr.chStr(z.getMaiguodongxi()) + "',pingjia='" +
        z.getPingjia()+ "',qubie='" + chStr.chStr(z.getQubie()) +
          "',gaijin='" + chStr.chStr(z.getGaijin()) +
          "',fabuxinxi='" + chStr.chStr(z.getFabuxinxi()) + "',zmzd='" +
          chStr.chStr(z.getZmzd()) + "',tjpy='" + chStr.chStr(z.getTjpy()) +
          "' where id=" + z.getId();
      ret = conn.executeUpdate(sql);
    }
    catch (Exception e) {
      ret = 0;
    }
    conn.close();
    return ret;
  }

  //执行删除操作
  public int delete(zaixiandiaocha z) {
     int ret=-1;
     try{
       String sql="Delete from zaixiandiaocha where id="+z.getId();
       ret=conn.executeUpdate(sql);
     }catch(Exception e){
       ret=0;
     }
     conn.close();
     return ret;

   }


  //执行查询操作
  public List select() {
   zaixiandiaocha form = null;
    List list = new ArrayList();
    String sql = "select * from zaixiandiaocha";
    ResultSet rs = conn.executeQuery(sql);
    try {
      while (rs.next()) {
        form = new zaixiandiaocha();
        form.setId(Integer.valueOf(rs.getString(1)));

        list.add(form);
      }
    }
    catch (SQLException ex) {
    }
    conn.close();
    return list;
  }

  public zaixiandiaocha select1() {
    return null;
  }

}

⌨️ 快捷键说明

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