• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invalid character constant

 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys anyone can tell me what is an invalid character constant ?
i compile my jsp file and it shows me this..

Invalid character constant. String queryText = "insert into sshl_account_application (employee_name, employee_number) values ('" + request.getParameter('employee_name') + "','" + request.getParameter('employee_number') + "')" ;
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The invalid character constant in this case is 'employee_name'. Single quotes in Java define a character constant, i.e. one character, e.g. 'a' or 'b' or '!'. 'employee_name' is a string of them so you have to use a String literal and double quotes, i.e. "employee_name".

When I said to use single quotes I meant in your SQL query string, e.g. String sql = "insert into table values ('string in sql')"; not in your Java code.

Jules
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you not using a PreparedStatement where you don't have to deal with all the SQL quoting issues?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic