2010-01-06 163 views
0

我想制作Restful - 使用netbean 6.5的web服务,glassfish v 2,并且我已经让表和表之间的关系了。但是,当我想测试RESTful Web服务,一些表显示它HTTP状态500

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. 

但有些表的工作。有人知道是什么原因导致这个问题,以及如何解决这个问题?谢谢。

THX安德鲁医学生,和吉姆Ferrans

我改变我所有的电子邮件到电子邮件。我不会忘记不要在DB中再添加“ - ”。 thx

回答

1

您需要引用“电子邮件”列名称,以便SQL解析器将接受它。没有引号/转义的短划线是SQL中的减法运算符,因此“E-mail”不加引号表示您要求SQL服务器减去名为“E”和“mail”的列的结果。

正确的SQL是:

SELECT Id, MobileNumber, Country, First_Name, `E-mail`, Address, Identity, Zip, Last_name, City, State, Position FROM employee_table WHERE (Id = ?) 
+0

Thx现在正在工作。我将所有电子邮件转换为电子邮件后。 – Huuhaacece 2010-01-06 05:02:17

+0

注意反向转义是一种非标准的MySQLism。根据ANSI SQL应该使用双引号。通过设置ANSI_QUOTES SQL_MODE可以获得此行为。 – bobince 2010-01-06 05:12:09

1

您在SQL查询(“电子邮件”)中有非法标识符。如果这是实际的列名,Andrew建议引用它是适当的解决方案。尽管你可能在查询中拼写错误。

+0

你的意思是什么,我必须改变电子邮件成别的东西? – Huuhaacece 2010-01-06 04:51:44

+0

这取决于您的列名在SQL模式中的真实含义。例如,如果它是“E_mail”,那么您只需要在查询中修复拼写。 – 2010-01-06 04:53:38

相关问题