今天进行了供货商页面的设计,对于数据的处理实现对应付金额的显示,对于登录显示用户名,明天进行补货,对于每个用户发送的信息进行补货。
package queren; import toolse.Tool; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; public class Daos { public List<Things> search(){ List<Things> list = new ArrayList<>(); try { Connection conn =Tool.getConnection(); String sql="select * from car_send " ; PreparedStatement pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ Things lu = new Things(); lu.setMer_phone(rs.getString("mer_phone")); lu.setTime(rs.getString("time")); lu.setAddress(rs.getString("address")); lu.setUser_phone(rs.getString("user_phone")); lu.setName(rs.getString("name")); lu.setTotal(rs.getInt("total")); list.add(lu); } rs.close(); pstmt.close(); conn.close(); }catch(SQLException e) { System.out.println("发生错误"); e.printStackTrace(); } return list; } public List<Things> searches(String name ,String time,String phone,String mer ){ List<Things> list = new ArrayList<>(); try { Connection conn =Tool.getConnection(); Statement state = null; String sql="select * from car_send where mer_phone= ? and name like '%"+name+"%' and time like '%"+time+"%' and user_phone like '%"+phone+"%' " ; PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setString(1, mer); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ Things lu = new Things(); lu.setMer_phone(rs.getString("mer_phone")); lu.setTime(rs.getString("time")); lu.setAddress(rs.getString("address")); lu.setUser_phone(rs.getString("user_phone")); lu.setName(rs.getString("name")); lu.setTotal(rs.getInt("total")); list.add(lu); } rs.close(); pstmt.close(); conn.close(); }catch(SQLException e) { System.out.println("发生错误"); e.printStackTrace(); } return list; } public int js(String name,String phone) { int price=0; try { Connection conn =Tool.getConnection(); String sql="select * from car_commodity where name = ? and user_phone = ?" ; PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setString(1, name); pstmt.setString(2,phone); ResultSet rs = pstmt.executeQuery(); while(rs.next()){ price=rs.getInt("price"); } rs.close(); pstmt.close(); conn.close(); }catch(SQLException e) { System.out.println("发生错误"); e.printStackTrace(); } return price; } }
标签:总结,getString,rs,每日,phone,lu,sql,4.20,pstmt From: https://www.cnblogs.com/syhxx/p/17338600.html