语法错误:表规范无效

时间:2015-05-29 06:40:46

标签: java sql sql-server syntax-error

从Sage 50检索数据时,我收到此错误。我用谷歌搜索但我找不到任何东西。逻辑上我认为我的表名在我的SQL查询中错误但我认为它们不是。我无法看到数据库,因为它是一个外部程序。

错误是:

  

语法错误:表规范无效

有没有人遇到过同样的问题?当我运行以下代码时:

String query = "SELECT TRAN_NUMBER,PAID_FLAG,AUDIT_USAGE.DATE, AUDIT_USAGE.DELETED_FLAG "
                + "FROM AUDIT_SPLIT FULL "
                + "OUTER JOIN AUDIT_USAGE ON AUDIT_USAGE.REFERENCE = AUDIT_SPLIT.INV_REF "
                + "AND AUDIT_USAGE.SPLIT_NUMBER = AUDIT_SPLIT.TRAN_NUMBER "
                + "WHERE NOMINAL_CODE = 2401 and AUDIT_SPLIT.DETAILS NOT LIKE 'Deleted%'";

我得到以下例外:

java.sql.SQLException: Syntax error: Invalid table specification
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)
    at org.apache.jsp.run_005fgovlevy_jsp._jspService(run_005fgovlevy_jsp.java:90)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:206)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:179)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

2 个答案:

答案 0 :(得分:0)

至少在ANSI SQL DATE中是保留字。双引它:

SELECT TRAN_NUMBER, PAID_FLAG, AUDIT_USAGE."DATE" ...

答案 1 :(得分:0)

无法找到适用于多个表的查询,因此我查询了每个表中的数据并将其保存到我的本地服务器并使用了上面的查询并且工作正常。