views:

132

answers:

2

I want to make Restful - Web Service using netbean 6.5, glassfish V 2 , and i already make table and the relationship between table. But when i want to test restful Webservice, some table it show

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'E' in 'field list'
Error Code: 1054
Call: SELECT Id, MobileNumber, Country, First_Name, E-mail, Address, Identity, Zip, Last_name, City, State, Position FROM employee_table WHERE (Id = ?)
    bind => [1]
Query: ReadObjectQuery(ws.EmployeeTable)

note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_02 logs.

but some table is working. Did someone know what cause this problem and how to handle this problem? Thx.

Thx to Andrew Medico, and Jim Ferrans

I change all my E-mail into email. and i will not forget to not add "-" in DB again. thx

+1  A: 

You've got an illegal identifier in an SQL query ("E-mail"). Andrew's suggestion to quote it is the proper solution if that's the actual column name. You may have mis-spelled it in the query though.

Jim Ferrans
What you mean i must change e-mail into something else?
Huuhaacece
It depends on what your column name really is in the SQL schema. If it's "E_mail" for example, then you just need to fix the spelling in your query.
Jim Ferrans
+1  A: 

You need to quote the "E-mail" column name so that the SQL parser will accept it. An unquoted/escaped dash is the subtraction operator in SQL, so "E-mail" unquoted means you're asking the SQL server for the result of subtracting columns named "E" and "mail".

The proper SQL would be:

SELECT Id, MobileNumber, Country, First_Name, `E-mail`, Address, Identity, Zip, Last_name, City, State, Position FROM employee_table WHERE (Id = ?)
Andrew Medico
Thx it's working now. after i change all E-mail into email.
Huuhaacece
Note backtick-escaping is a non-standard MySQLism. According to ANSI SQL double-quotes should be used. This behaviour can be gained by setting the ANSI_QUOTES SQL_MODE.
bobince