File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with update and create methods in MVC

 
Ana Pan
Greenhorn
Posts: 4
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a login MVC, where in my model User.java 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
1

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

This is my model User.java


This is my controller UserSystem.java



Big THANK YOU in advance!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64190
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Copied to the JDBC forum as this seems to be primarily JDBC issues.
 
Ankit Dan
Ranch Hand
Posts: 47
Eclipse IDE Java MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be less error prone, and more secure, to use PreparedStatements with parameters to create all these queries.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic