Question
THE QUESTION : So I'm using Netbeans and derby (the database from Netbeans). There is no error in the code but the data that I
THE QUESTION :
So I'm using Netbeans and derby (the database from Netbeans). There is no error in the code but the data that I inserted did not display on the database. Ignore the comment */ thing. Please help me fix the code.
// BELOW IS THE RESERVATIONMANAGER (this one link with the database I think)
public class ReservationManager { private ArrayList
// THIS ONE IS THE MANAGERESERVATION (Where I insert data and all that)
public class ManageReservation extends javax.swing.JFrame { private ReservationManager manager = new ReservationManager(); private Reservation reservation; public ManageReservation() { initComponents();
initialBtn(); }
private void initialBtn(){ saveBtn.setEnabled(true); updateBtn.setEnabled(false); deleteBtn.setEnabled(false); resetBtn.setEnabled(false); } // Method definition: Check whether the form are completed or empty private boolean isEmptyField(){ // Check each field is empty if(nameTxtField.getText().isEmpty() || destinationBox.getSelectedIndex() == -1 || departuretimeBox.getSelectedIndex() == -1 || idTxtField.getText().isEmpty() || dateChooser1.getDate() == null || fromBox.getSelectedIndex() == -1) { // if empty, return true return true; } else { // if complete, return false return false; } } private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // Check if the form is completed if(!isEmptyField()) { // Create new item object to receive input Reservation newReservation = new Reservation(); // Call methods at class Item to set the new value from the form newReservation.setReservationName(nameTxtField.getText().trim()); newReservation.setReservationID((String)idTxtField.getText().trim()); newReservation.setReservationDate((java.sql.Date) dateChooser1.getDate()); newReservation.setReservationStartingFrom((String)fromBox.getSelectedItem()); newReservation.setReservationDestination((String)destinationBox.getSelectedItem()); newReservation.setReservationDepartureTime((String)departuretimeBox.getSelectedItem()); // Call method to save the reservation manager.saveReservation(reservation); JOptionPane.showMessageDialog(null, "The item has been saved!"); clearForm(); } // If the form is not completed yet else { // Display information message box JOptionPane.showMessageDialog(null, "Complete the form!"); } } // Call method to set initial buttons state initialBtn(); // Call method to reset the form clearForm(); // Stop the loop to find the item to be edited break; } // If do not found the selected item yet else { // Continue to read the next item object in the ArrayList continue; } } } // If the form is not completed yet else{ // Display information message box JOptionPane.showMessageDialog(null, "Complete the form!"); } */ }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started