Guest User

Untitled

a guest
Jan 25th, 2016
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2. String url = "jdbc:derby://localhost:1527/Members";
  3. String username = "admin1";
  4. String password = "admin1";
  5.  
  6. Connection con = DriverManager.getConnection(url, username, password);
  7. Statement stmt = con.createStatement();
  8.  
  9. String query = "INSERT INTO BOOKING(MEMBERID, NAME, CONTACT, "
  10. + "EMAILADDRESS, RESERVATIONDATE, RESERVATIONTIME) "
  11. + "VALUES('"+txtMemberID.getText()+"', '"+txtName.getText()+"', "
  12. + "'"+txtContact.getText()+"', '"+txtEmail.getText()+"', "
  13. + "'"+comboDate.getDate()+"', '"+comboTime.getSelectedItem()+"')";
  14.  
  15. stmt.execute(query);
  16.  
  17. JOptionPane.showMessageDialog(null, "Booking created");
  18.  
  19. txtMemberID.setText(null);
  20. txtName.setText(null);
  21. txtContact.setText(null);
  22. txtEmail.setText(null);
  23. comboDate.setDate(null);
  24. comboTime.setSelectedItem("00");
  25.  
  26. }
  27. catch(SQLException ex) {
  28. JOptionPane.showMessageDialog(null, ex.toString());
  29. }
RAW Paste Data