• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

invalid character constant

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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') + "')" ;
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic