help! - illegal state of expression

Reply

Join Date: Aug 2009
Posts: 2
Reputation: mithunthakkar is an unknown quantity at this point 
Solved Threads: 0
mithunthakkar mithunthakkar is offline Offline
Newbie Poster

help! - illegal state of expression

 
0
  #1
Aug 21st, 2009
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+);
}
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: help! - illegal state of expression

 
0
  #2
Aug 21st, 2009
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,




  1. if(c.equals("BillNo")){
  2. /*--error--*/ rs = stmt.executeQuery("select * from orders where billNo="+a+);
  3. }else if(c.equals("UserId")){
  4. /*--error--*/ rs = stmt.executeQuery("select * from orders where userid="+a+);
  5. }
  6. else if(c.equals("ProductId")){
  7. /*--error--*/ rs = stmt.executeQuery("select * from orders where productid="+a+);
  8. }


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.


[code=java]
// Your code here
[/code]
Last edited by stephen84s; Aug 21st, 2009 at 3:06 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 2
Reputation: mithunthakkar is an unknown quantity at this point 
Solved Threads: 0
mithunthakkar mithunthakkar is offline Offline
Newbie Poster

Re: help! - illegal state of expression

 
0
  #3
Aug 21st, 2009
ya thanx man
i got that
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC