aspose file tools*
The moose likes JDBC and the fly likes missing expression error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "missing expression error" Watch "missing expression error" New topic
Author

missing expression error

krish acc
Greenhorn

Joined: Sep 02, 2005
Posts: 2
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

Joined: Apr 19, 2005
Posts: 8
r u using connection after con.close() ?


venu gopal p
krish acc
Greenhorn

Joined: Sep 02, 2005
Posts: 2
no i have closed the connection in the last of the statements.
Choon-Chern Lim
Ranch Hand

Joined: Aug 29, 2005
Posts: 74
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

Joined: Jan 10, 2002
Posts: 60055
    
  65

Moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sweta naidu
Greenhorn

Joined: Nov 02, 2004
Posts: 25
return count; move that statement after catch block and try to run.
Makarand Parab
Ranch Hand

Joined: Dec 10, 2004
Posts: 121
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: missing expression error
 
Similar Threads
Table Relationship
JDBC help
Display the sequence numbers on the output rows of a select in Oracle 10g
Error
Oracle J developer :Database connectivity