public String doPartialUpdate() { String back = ""; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; String str = ""; String qq = ""; con = Helper.getConnection(); if (con == null) { back = "Could not connect to DB"; addError(back); return back; } try { qq = "update monitors set " + "asset_num=?, screen_size=?,received=?, expected_age=?, " + "notes=? " + "where id=?"; if (debug) { logger.debug(qq); } pstmt = con.prepareStatement(qq); int jj = 1; if (asset_num.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, asset_num); if (screen_size.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, screen_size); if (received.equals("")) pstmt.setNull(jj++, Types.DATE); else pstmt.setDate(jj++, new java.sql.Date(dateFormat.parse(received).getTime())); pstmt.setString(jj++, "" + expected_age); if (notes.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, notes); pstmt.setString(6, id); pstmt.executeUpdate(); } catch (Exception ex) { back += ex + ":" + qq; logger.error(back); addError(back); } finally { Helper.databaseDisconnect(con, pstmt, rs); } if (back.equals("")) { back = doSelect(); } return back; }
String fillPStatement(PreparedStatement pstmt) { String back = ""; int jj = 1; try { if (external_id.equals("")) pstmt.setNull(jj++, Types.INTEGER); else pstmt.setString(jj++, external_id); if (device_id.equals("")) pstmt.setNull(jj++, Types.INTEGER); else pstmt.setString(jj++, device_id); if (name.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, name); if (asset_num.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, asset_num); if (serial_num.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, serial_num); if (screen_size.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, screen_size); if (model.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, model); if (type.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, type); if (vertical_resolution.equals("")) pstmt.setNull(jj++, Types.INTEGER); else pstmt.setString(jj++, vertical_resolution); if (horizontal_resolution.equals("")) pstmt.setNull(jj++, Types.INTEGER); else pstmt.setString(jj++, horizontal_resolution); if (manufacturer.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, manufacturer); if (received.equals("")) pstmt.setNull(jj++, Types.DATE); else pstmt.setDate(jj++, new java.sql.Date(dateFormat.parse(received).getTime())); pstmt.setString(jj++, "" + expected_age); if (id.equals("")) { status = "Active"; } // otherwise we skip status if (notes.equals("")) pstmt.setNull(jj++, Types.VARCHAR); else pstmt.setString(jj++, notes); editable = "y"; } catch (Exception ex) { logger.error(ex); back += ex; } return back; }