| | |
help! - illegal state of expression
![]() |
•
•
Join Date: Aug 2009
Posts: 2
Reputation:
Solved Threads: 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+);
}
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+);
}
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,
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]
java Syntax (Toggle Plain Text)
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.
[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 ?"
"How to ask questions the smart way ?"
![]() |
Similar Threads
- Illegal start of expresion (Java)
- illegal start of expression (Java)
- JAVA Illegal Start of Expression Error (Java)
- Fibonacci Recursion - Illegal Start of expression! (Java)
- illegal start of expression (Java)
- Why illegal start of expression error? (Java)
- illegal start of expression (Java)
Other Threads in the Java Forum
- Previous Thread: Unknown error
- Next Thread: urgent help
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card chat class client code collision component crashcourse css csv database eclipse ee error fractal free game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linux list loan machine map method methods migrate mobile netbeans newbie objects oriented output panel phone physics problem program programming project projects radio recursion replaydirector reporting scanner se server service set sms socket software sort sql string swing test textfield threads transfer tree trolltech ubuntu utility windows






