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 invalid character constant 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 "invalid character constant" Watch "invalid character constant" New topic
Author

invalid character constant

mary bate
Greenhorn

Joined: Jul 30, 2004
Posts: 12
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

Joined: Aug 02, 2004
Posts: 823
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

Joined: Jan 10, 2002
Posts: 60794
    
  65

Why are you not using a PreparedStatement where you don't have to deal with all the SQL quoting issues?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: invalid character constant
 
Similar Threads
help needed
how can I assign a unicode value to a char variable?
character representation of a blank space
is this statement correct?
Clustered index on a DB table