jdbc.BadSqlGrammarException表或视图不存在。在数据库中测试查询,工作。但Web应用程序错误

时间:2012-10-23 22:32:17

标签: sql oracle spring jdbc

  

编辑:已修复!请看下面

所以我在SQL Developer中测试了查询,它运行正常。但是,在我的实现中,运行不会将数据加载到列表中并吐出此错误:

  

org.springframework.jdbc.BadSqlGrammarException:PreparedStatementCallback;坏       SQL语法[select columnname,displayname,viewsortorder,capsdisind,window,DIS       FIELDID,(从WEB_CUSTDISABLEDFIELDS中选择1,其中custid =?AND A.DISFIELD       ID = WEB_CUSTDISABLEDFIELDS.DISFIELDID)来自web_DISABLEDFIELDS A];嵌套的前       ception是java.sql.SQLSyntaxErrorException:ORA-00942:表或视图不存在
          在org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.d       oTranslate(SQLErrorCodeSQLExceptionTranslator.java:220)               在org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslat       or.translate(AbstractFallbackSQLExceptionTranslator.java:72)               在org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:       607)               在org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:64       1)               在org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:67       0)               在org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:67       8)               在org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:71       0)               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)               at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)               at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)               at java.lang.reflect.Method.invoke(Unknown Source)               在flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdap)       ter.java:421)               在flex.messaging.services.RemotingService.serviceMessage(RemotingServic       e.java:183)               在flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java)       :1503)               在flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndp       oint.java:884)               在flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBroker)       Filter.java:121)               在flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:15       8)               在flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:       44)               在flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFi       lter.java:67)               在flex.messaging.endpoints.amf.SerializationFilter.invoke(序列化       Filter.java:146)               在flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.ja       VA:278)               在flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java)       :322)               在javax.servlet.http.HttpServlet.service(HttpServlet.java:722)               在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl       icationFilterChain.java:304)               在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF       ilterChain.java:210)               在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV)       alve.java:224)               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV)       alve.java:175)               在org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica)       torBase.java:472)               在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j       AVA:164)               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j       AVA:100)               在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:       929)               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal)       ve.java:118)               在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav)       一:405)               在org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcesso)       r.java:316)               at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(       AbstractProtocol.java:515)               在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoin)       t.java:1544)               at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)               at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)               在java.lang.Thread.run(未知来源)       引起:java.sql.SQLSyntaxErrorException:ORA-00942:表或视图不存在        在oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.ja)       VA:91)               at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:1       12)               at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java       :173)               at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)               at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)               at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)               在oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement。       Java的:194)               at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPrepare       dStatement.java:785)               at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPrepa)       redStatement.java:860)               at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme       nt.java:1186)               at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrep       aredStatement.java:3381)               在oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePrepare       dStatement.java:3425)               在oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(Oracle       PreparedStatementWrapper.java:1490)               在org.springframework.jdbc.core.JdbcTemplate $ 1.doInPreparedStatement(Jd       bcTemplate.java:648)               在org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:       591)               ... 39更多

我已经使用此错误搜索了多个问题,但它们似乎都没有解决与地雷相同的问题。我正在使用Oracle SQL。

也许有人之前遇到过这个问题?任何帮助表示赞赏。谢谢!

解决问题

问题在于表格。他们只需要访问数据库中的权限。

我做的是:

grant all on sa.table to public
/
create public synonym table for sa.table
/
grant all on sa.table2 to public
/
create public synonym table2 for sa.table2
/

1 个答案:

答案 0 :(得分:2)

您的网络应用最有可能登录的是与您的表格不同的架构

尝试在sql语句中明确指定模式。即:

SELECT a, b FROM user.TABLE