Frnds
2010-09-07 20:18:33 UTC
try{
con = DriverManager.getConnection("jdbc:mysql:…
stmt = con.createStatement();
String rt = (String)rtcb.getSelectedItem();
if(rt.equals("Single")){
String query = "select roomno from room where roomtype = 'Single' ;";
System.out.println(query);
ResultSet rs = stmt.executeQuery(query);
rncb.addItem(rs.getString("Roomno"));
}
else if (rt.equals("Double")){
String query = "select roomno from room where roomtype = 'Double' ;" ;
System.out.println(query);
ResultSet rs = stmt.executeQuery(query);
rncb.addItem(rs.getString("Roomno"));
}
else{
String query = "select roomno from room where roomtype = 'Triple' ;" ;
System.out.println(query);
ResultSet rs = stmt.executeQuery(query);
rncb.addItem(rs.getString("Roomno"));
}
}
catch(Exception e){
op.showMessageDialog(null,"Error in connection " + e);
}
}
CREATE TABLE ROOM
(ROOMNO INT(5) PRIMARY KEY,
ROOMTYPE VARCHAR(15) NOT NULL,
NOOFBEDS INT(10) NOT NULL,
MONTHLYFEE DECIMAL(9,2));