This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem with update and create methods in MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with update and create methods in MVC" Watch "Problem with update and create methods in MVC" New topic

Problem with update and create methods in MVC

Ana Pan

Joined: Oct 23, 2012
Posts: 4

Hello all,

I have a login MVC, where in my model I have 2 methods that are not working correctly:

1-create method creates a new user in database, but servlet still redirects me to "operation failed" page
2-update method shows this when deployed:
java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT userId FROM user WHERE username='oksana' AND password ='oksana'' at line

Can somebody please help me to understand what I am doing wrong here.

This is my model

This is my controller

Big THANK YOU in advance!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60785

Copied to the JDBC forum as this seems to be primarily JDBC issues.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ankit Dan
Ranch Hand

Joined: Aug 31, 2012
Posts: 47

the problem is in line no 85

and line no 89

as you are trying to assign the whole query to userid instead of storing the result from query1 to userId
hope this helps...
Sresh Rangi
Ranch Hand

Joined: Nov 28, 2012
Posts: 45
It would be less error prone, and more secure, to use PreparedStatements with parameters to create all these queries.
jQuery in Action, 2nd edition
subject: Problem with update and create methods in MVC
Similar Threads
unable to forward using jsp:forward
Always responding invalidLogin.jsp
My login application accepts any and all username/passwords.
How to use httpsession with dao factory
connectio null problem