Here I am getting values from the jsp page
String ACRoom = request.getParameter("ACRoom");
String NACRoom = request.getParameter("NOACRoom");
String Bed = request.getParameter("ACBed");
String NACBed = request.getParameter("NOACBed");
This is my table
ROOM_NO AVAIL_BED1 AVAIL_BED2
I want to insert data into available bed column in selected room no. If one bed is full then insert data into second bed column else first . If new room no is selected then insert new record else insert data into existing room no.
try
{
if ("ac".equals(Room[0])) {
{
PreparedStatement ps = con.prepareStatement("insert into Available_AC_Room values(?,?,?,?,?,?)");
ps.setString(1,ID);
ps.setString(2,ACRoom);
ps.setString(3,Bed);
ps.setString(4,Bed);
ps.setString(5,ACDueDt);
ps.setString(6,RT);
ps.executeQuery();
}
else {
PreparedStatement ps = con.prepareStatement("insert into Available_NON_AC_Room values(?,?,?,?,?,?)");
ps.setString(1,ID);
ps.setString(2,NACRoom);
ps.setString(3,NACBed);
ps.setString(4,NACBed);
ps.setString(5,NACDueDt);
ps.setString(6,ST);
ps.executeQuery();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
This row is for select room no from drop downlist
<div class="col-30">
<label for="Room"><b>Non AC-Room</b>
</label> <select class="col-Room" name="NOACRoom">
<%
while (st.next()) {
%>
<option><%=st.getString(1)%></option>
<%
}
%>
</select>
</div>
<div class="col-30">
<label for="Chair"><b>Alloted Chairs</b>
</label>
<div id="idno">
<input type="text" placeholder="Chairs" name="NOACChair" required>
</div>
</div>
<div class="col-30">
<label for="Bed"><b>Alloted Bed</b>
</label>
<div id="idno">
<input type="text" placeholder="Bed" name="NOACBed" required>
</div>
</div>