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+);
            }

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.