示例#1
0
 public ProfileDto profile(String id) {
   Connection con = null;
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try {
     con = DbcpBean.getConn();
     String sql = "select * from profile where id=?";
     pstmt = con.prepareStatement(sql);
     pstmt.setString(1, id);
     rs = pstmt.executeQuery();
     if (rs.next()) {
       ProfileDto dto =
           new ProfileDto(
               rs.getInt("pnum"),
               id,
               rs.getString("comments"),
               rs.getString("orgfilename"),
               rs.getString("savefilename"),
               rs.getInt("filesize"));
       return dto;
     } else {
       return null;
     }
   } catch (SQLException se) {
     System.out.println(se.getMessage());
     return null;
   } finally {
     JdbcUtil.closeDB(con, pstmt, rs);
   }
 }
示例#2
0
 public int c_update(HashMap<String, String> map) {
   Connection con = null;
   PreparedStatement pstmt = null;
   try {
     con = DbcpBean.getConn();
     String sql = "update profile set comments=? where id=?";
     pstmt = con.prepareStatement(sql);
     pstmt.setString(1, map.get("comments"));
     pstmt.setString(2, map.get("id"));
     return pstmt.executeUpdate();
   } catch (SQLException se) {
     System.out.println(se.getMessage());
     return 0;
   } finally {
     JdbcUtil.closeDB(con, pstmt, null);
   }
 }
示例#3
0
 public int p_pupdate(ProfileDto dto) {
   Connection con = null;
   PreparedStatement pstmt = null;
   try {
     con = DbcpBean.getConn();
     String sql = "update profile set orgfilename=?, savefilename=?, filesize=? where id=?";
     pstmt = con.prepareStatement(sql);
     pstmt.setString(1, dto.getOrgfilename());
     pstmt.setString(2, dto.getSavefilename());
     pstmt.setLong(3, dto.getFilesize());
     pstmt.setString(4, dto.getId());
     return pstmt.executeUpdate();
   } catch (SQLException se) {
     System.out.println(se.getMessage());
     return 0;
   } finally {
     JdbcUtil.closeDB(con, pstmt, null);
   }
 }