• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

missing expression error

 
krish acc
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

While trying to execute the following code am getting an error..

exception

javax.servlet.ServletException: [Oracle][ODBC][Ora]ORA-00936: missing expression

and
root cause

java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00936: missing expression

its working till the executeupdate statement....could someone please help me out


public int addNewUser(){
int count=0;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc dbc racleDSN","groupIII","groupIII");
PreparedStatement ps=con.prepareStatement("Insert into Registration values (?,?,?,?,?,?,?,?)");
ps.setString(1,firstName);
ps.setString(2,lastName);
ps.setString(3,gender);
ps.setString(4,userId);
ps.setString(5,password);
ps.setString(6,occupation);
ps.setString(7,address);
ps.setString(8,location);
count=ps.executeUpdate();
con.close();
return count;
}
catch(Exception e){
System.out.println("in new user");
return count;
}
}
 
pippiri venu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
r u using connection after con.close() ?
 
krish acc
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i have closed the connection in the last of the statements.
 
Choon-Chern Lim
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I maybe wrong, but it sounds like sql syntax error to me. Other than that, everything looks okay to me.

Can you try having this as your sql statement in your preparedStatement?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
 
sweta naidu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
return count; move that statement after catch block and try to run.
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
This is what ur error says
ORA-00936: missing expression
Cause: A required part of a clause or expression has been omitted. For example, a SELECT statement may have been entered without a list of columns or expressions or with an incomplete expression. This message is also issued in cases where a reserved word is misused, as in SELECT TABLE.
Action: Check the statement syntax and specify the missing component.


Do one thing as
Implement SQL is this way
Insert into Registration (firstName, lastName, gender, userid, password, occupation, address, location) values (?,?,?,?,?,?,?,?)

Regards
Makarand Parab
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic