GUI
package Trial;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
class Demo {
JButton jb1;
JCheckBox cb1, cb2, cb3;
JComboBox comRoomNo;
Demo() {
JFrame frame = new JFrame();
frame.setTitle("Hancie e-Learning Studio");
frame.setLayout(null);
frame.setSize(600, 500);
frame.setLocationRelativeTo(null);
comRoomNo = new JComboBox();
comRoomNo.setBounds(159, 23, 206, 34);
frame.add(comRoomNo);
comRoomNo.setFont(new Font("Times New Roman", Font.PLAIN, 16));
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/" +
"hotel_database", "root",
"");
String query1 = "select customers.Customer_ID, customers.Name,"
+ " booking.Booking_ID, booking.CheckIn, booking.CheckOut,"
+ " booking.Room_ID,booking.Booking_Type, booking.Booking_Status"
+ " from booking left join customers on booking.Customer_ID = " +
"customers.Customer_ID;";
PreparedStatement pst1 = conn.prepareStatement(query1);
ResultSet rst1 = pst1.executeQuery();
String Booking_ID = "";
while (rst1.next()) {
comRoomNo.addItem(rst1.getString("Booking_ID"));
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
frame.setVisible(true);
}
public static void main(String args[]) {
new Demo();
}
}
Output