Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. public class NewJFrame extends javax.swing.JFrame {
  2.  
  3. public NewJFrame() {
  4.  
  5.  
  6. initComponents();
  7. setTitle("Found Items");
  8. try {
  9. String myDriver = "com.mysql.cj.jdbc.Driver";
  10. String myUrl = "jdbc:mysql://localhost:3306/lostfound";
  11. Class.forName(myDriver);
  12. Connection c = DriverManager.getConnection(myUrl, "root", "");
  13. String sql = "SELECT * FROM found";
  14. Statement st = c.createStatement();
  15.  
  16. // execute the query, and get a java resultset
  17. ResultSet rs =st.executeQuery(sql);
  18. int row =0;
  19. while(rs.next())
  20. {
  21. private static final int BOOLEAN_COLUMN = 4;
  22. String name = rs.getString("name");
  23. String description = rs.getString("description");
  24. String location = rs.getString("location");
  25. meza.getModel().setValueAt(name, row, 0);
  26. meza.getModel().setValueAt(description, row, 1);
  27. meza.getModel().setValueAt(location, row, 2);
  28. row++;
  29.  
  30. }
  31.  
  32. }
  33. catch (SQLException e)
  34. {
  35. System.out.println( e.getMessage() );
  36. } catch (ClassNotFoundException ex) {
  37. Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
  38. }
  39. meza.show();
  40. claim.addActionListener(new ActionListener() {
  41. @Override
  42. public void actionPerformed(ActionEvent e) {
  43. for(int i =0; i<meza.getRowCount(); i++)
  44. {
  45. Boolean checked = Boolean.valueOf(meza.getValueAt(i,3).toString());
  46. String col = meza.getValueAt(i, 1).toString();
  47. //DISPLAY POP UP
  48. if(checked)
  49. {
  50. JOptionPane.showMessageDialog(null,col);
  51. }
  52. }
  53. }
  54. });
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement