943,678 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 468
  • Java RSS
Aug 21st, 2009
0

help! - illegal state of expression

Expand Post »
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+);
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mithunthakkar is offline Offline
2 posts
since Aug 2009
Aug 21st, 2009
0

Re: help! - illegal state of expression

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,




java Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Aug 21st, 2009
0

Re: help! - illegal state of expression

ya thanx man
i got that
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mithunthakkar is offline Offline
2 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Unknown error
Next Thread in Java Forum Timeline: urgent help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC