文件名称:个人信息助理系统
文件大小:2.18MB
文件格式:ZIP
更新时间:2018-02-03 16:43:40
系统 package com.neusoft.dao.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.neusoft.entity.Group; import com.neusoft.entity.Person; import com.neusoft.util.DbUtil; public class PersonTableDao { public static final String SQL1= "insert into Person_Table"+" (p_id,g_name,p_name,p_birthday,p_phone,p_Email,p_address)"+" values(?,?,?,?,?,?,?)"; public static final String SQL2= "update Person_Table set p_id=?,g_name=?,p_birthday=to_date(?,'dd-mm-yyyy'),p_phone=?,p_Email=?,p_address=? where p_name=?"; public static final String SQL3= "delete from Person_Table where p_name=?"; public static final String SQL4= "select * from Person_Table"; public static final String SQL5= "select * from Person_Table where p_name = ?"; public boolean addPerson(Person person){ Connection conn = null; PreparedStatement stmt = null; conn = DbUtil.getConn(); try { stmt = conn.prepareStatement(SQL1); //向Person_Table中插入数据 stmt.setInt(1,person.getP_id()); stmt.setString(2,person.getG_name()); stmt.setString(3,person.getP_name()); stmt.setDate(4,new java.sql.Date(person.getP_birthday().getTime())); stmt.setString(5,person.getP_phone()); stmt.setString(6,person.getP_Email()); stmt.setString(7,person.getP_address()); int rows = stmt.executeUpdate(); if(rows>0) return true; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); }finally{ DbUtil.getClose(conn, stmt); } return false; } public boolean updatePersonMessage(Person person){ Connection conn = null; PreparedStatement stmt = null; conn = DbUtil.getConn(); try { stmt = conn.prepareStatement(SQL2);//根据p_name更新person表中的数据。 stmt.setInt(1,person.getP_id()); stmt.setString(2,person.getG_name()); stmt.setDate(3,new java.sql.Date(person.getP_birthday().getTime())); stmt.setString(4,person.getP_phone()); stmt.setString(5,person.getP_Email()); stmt.setString(6,person.getP_address()); stmt.setString(7,person.getG_name()); int rows = stmt.executeUpdate(); if(rows>0) return true; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); }finally{ DbUtil.getClose(conn, stmt); } return false; } public boolean deletePersonMessage(String p_name){ Connection conn = null; PreparedStatement stmt = null; conn = DbUtil.getConn(); try { stmt = conn.prepareStatement(SQL3);//根据p_name删除person表中对应的数据。 stmt.setString(1,p_name); int rows = stmt.executeUpdate(); if(rows>0) return true; } catch (SQLException e) { // TODO: handle exception e.printStackTrace(); }finally{ DbUtil.getClose(conn, stmt); } return false; } public List