Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

error in executing mysql statement

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





error is :

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 ''4'' at line 1

\\i entered 4 in text box...
thanks in advance
 
Rancher
Posts: 903
22
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how to use your debugger?  If so please put a break on your "ResultSet rs = " line and debug the program, when you hit that breakpoint please post the full SQL statement that you have in your execution path--the resulting SQL statement after your variables are evaluated or enter that SQL directly into your MySQL editor and see what error message you get.  Once we have the SQL statement that is causing the problem, then we can look at getting an answer, but before then I'm not looking further.

ramesh suresh wrote:




error is :

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 ''4'' at line 1

\\i entered 4 in text box...
thanks in advance

 
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Don't quote number. Your query contains limit '4' where it should be limit 4 - without quotes.
2) You will probably need to put backticks (`) around transaction (`transaction`), because that's a reserved word.
3) Use a PreparedStatement to prevent SQL injection with the account number.
4) Make sure that number is numeric to prevent SQL injection.
 
    Bookmark Topic Watch Topic
  • New Topic