aspose file tools*
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
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: 61764
    
  67

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invalid character constant