Expand|Select|Wrap|Line Numbers
- 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.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**