**Below is my code in my jsp file**
<table class="table" style="width:30%;">
<tr > <td>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
Select product
</button>
**Below is my sql query I used... When I click on dropdown on my jsp webpage, and select a product from the list, that product's ID must be fetched and update in another table in same database. Please help me how to resolve this issue.**
public void selectProductsString(RecipieColumns2 rc2) throws SQLException {
1. I have a jsp file which has dropdown containing product names which are fetched from the sql table. 2. My problem is, when i click the product name from the drop down, it should fetch the productID associated with the product name from the database and that product ID should be updated in another table. So everytime I select product name, it's product ID must be updated in another SQL table**
String sql1 = "select Products from [09RE]where RecName='Roasted Turkey Sandwich' and UU='uma'";
Connection connection = getConnection();
StringBuilder builder = new StringBuilder();
try{
PreparedStatement statement = connection.prepareStatement(sql1);
ResultSet results = statement.executeQuery();
while(results.next()){
String Products = results.getString("Products");
String Product_list[] = Products.split(",");
String sql = "select id from [09PR] where ProdName=? and UU='uma'";
PreparedStatement statement1 = connection.prepareStatement(sql);
//statement1.setString(1, rc2.getProdName());
ResultSet results1 = statement1.executeQuery();
while(results1.next()){
String displaysql = sql;
String id = results1.getString("id");
builder.append(Products+","+id);
String totalProducts = builder.toString();
String sql2 = "update [09RE] set Products ='" + totalProducts +"' where UU='uma'";
PreparedStatement statement2 = connection.prepareStatement(sql2);
statement2.executeQuery();
}
}
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
closeConnection(connection);
}
}
1. First code is jsp file which has dropdown containing product names which are fetched from the sql table. 2. My problem is, when i click the product name from the drop down, it should fetch the productID associated with the product name from the database and that product ID should be updated in another table. So everytime I select product name, it's product ID must be updated in another SQL table**