在eclipse项目中,执行sql任务时出现这样的错误:Running: select * from account
account: is exist in Oracle
Exception in thread "main" java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:113)
at oracle.jdbc.driver.T4CStatement.execute_for_describe(T4CStatement.java:431)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:965)
at oracle.jdbc.driver.T4CStatement.execute_maybe_describe(T4CStatement.java:463)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1051)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1184)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
at com.zjhcsoft.venus.jdbc.VenusStatement.executeQuery(VenusStatement.java:198)
at com.zjhcsoft.venus.jdbc.VenusJdbcClient.main(VenusJdbcClient.java:70)
>>所以说,account表的确在Oracle数据库中,但是为何会出现这种情况呢?经过查找资料发现,原来这是因为定义account的表的时候,加了双引号""的原因,从而导致在写sql语句的时候,必须加上双引号,由于双引号是特殊字符,所以需要再加上转义字符。也就是 sql = "select * from \"account\"";这样就Okay了!但是与书写sql语句的习惯不符,写起来也麻烦。。。 >>Oracle建表时,如建表的SQL同时满足以下条件,则不论在查询或新增数据时都必须把相应SQL中表名用引号括起来,否则会报00942错误。
1)建表的SQL中表名用引号括起来了。
2)建表的SQL中表名中英文字符不全部都是大写。
>>解决办法:就是强烈建表时不要把表名用""括起来!
阅读(1393) | 评论(0) | 转发(0) |