首页>代码>jsp+servlet+easyUI+jquery+echarts开发高速公路事故后台信息管理系统>/OneProject/src/com/wu/action/CarHostImpl.java
package com.wu.action; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import com.wu.Service.CarHostI; import com.wu.bean.CarUser; import com.wu.util.DbUtil; import com.wu.util.jsonUtil; import net.sf.json.JSONArray; public class CarHostImpl implements CarHostI { @Override public boolean AddCarUser(CarUser car) { boolean flag = false; Connection conn = null; PreparedStatement pst = null; int result = 0; String sql = "insert into caruser values(?,?,?,?,?)"; try { conn = DbUtil.getConnection(); pst = conn.prepareStatement(sql); pst.setInt(1, car.getCars_Id()); pst.setString(2, car.getUsers_Name()); pst.setString(3, car.getUsers_Tel()); pst.setString(4,car.getUsers_Address()); pst.setString(5, car.getUsers_sex()); result = pst.executeUpdate(); conn.setAutoCommit(true); DbUtil.closeAll(); if (result != 0) { return true; } } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return false; } @Override public boolean Update(CarUser car) { boolean flag = false; Connection conn = null; PreparedStatement pst = null; int result = 0; String sql = "update caruser set Users_Name=? , Users_Tel=? , Users_sex=? , Users_address=? where Cars_Id=? "; try { conn = DbUtil.getConnection(); pst = conn.prepareStatement(sql); pst.setString(1, car.getUsers_Name()); pst.setString(2, car.getUsers_Tel()); pst.setString(3, car.getUsers_sex()); pst.setString(4, car.getUsers_Address()); pst.setInt(5, car.getCars_Id()); result = pst.executeUpdate(); conn.setAutoCommit(true); DbUtil.closeAll(); if (result != 0) { return true; } } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return false; } @Override public JSONArray selAll() { JSONArray jsonArray = null; String sql = "select * from caruser"; Connection conn = null; PreparedStatement pst = null; ResultSet rs = null; try { conn = DbUtil.getConnection(); pst = conn.prepareStatement(sql); rs = pst.executeQuery(); jsonArray = jsonUtil.formatRsToJsonArray(rs); DbUtil.closeAll(); } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return jsonArray; } @Override public JSONArray search(int carid) { JSONArray jsonArray = null; String sql = "select * from caruser where Cars_Id=?"; Connection conn = null; PreparedStatement pst = null; ResultSet rs = null; try { conn = DbUtil.getConnection(); pst = conn.prepareStatement(sql); pst.setInt(1, carid); rs = pst.executeQuery(); jsonArray = jsonUtil.formatRsToJsonArray(rs); DbUtil.closeAll(); } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return jsonArray; } }

171337601 LV9
2022年4月18日
nitama LV19
2021年5月16日
ericxu1116 LV24
2021年4月26日
rebecca0214 LV2
2021年4月14日
ly_fxm LV4
2021年1月31日
naixia LV9
2020年7月8日
芳华林 LV11
2020年6月18日
骄傲的时刻 LV2
2020年5月16日
KING QIN LV5
2020年5月12日
TerryGaoBo LV9
2020年4月28日