0

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 by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by mithunthakkar
0

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 by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.