hey friends,
im getting this error illegal state of expression
plz help me wid this

Connection db = DriverManager.getConnection(connectURL);
            Statement stmt = db.createStatement();
            String c = request.getParameter("criteria");
            String a = request.getParameter("value");
            ResultSet rs;
            if(c.equals("BillNo")){                
--error--                rs = stmt.executeQuery("select * from orders where billNo="+a+);
            }else if(c.equals("UserId")){
--error--           rs = stmt.executeQuery("select * from orders where userid="+a+);
            }
            else if(c.equals("ProductId")){
 --error--        rs = stmt.executeQuery("select * from orders where productid="+a+);
            }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This is just plain old Java syntax error, the operator "+" in Java is used to concatenate String objects, remove the extra plus after "a" in all the three statements and you should be good to go,

if(c.equals("BillNo")){
/*--error--*/ rs = stmt.executeQuery("select * from orders where billNo="+a+);
}else if(c.equals("UserId")){
/*--error--*/ rs = stmt.executeQuery("select * from orders where userid="+a+);
}
else if(c.equals("ProductId")){
/*--error--*/ rs = stmt.executeQuery("select * from orders where productid="+a+);
} 

Also just a point to remember next time wrap your code inside code tags as shown below it will give you syntax highlighting as shown above.

Edited 3 Years Ago by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.