0
我嘗試使用下面的SQL查詢數據庫:壞的SQL語法 - 的Java JDBC
select round(b.Used_space*100/a.tablespace_size,2)
from
(select tablespace_name,sum(bytes/1024/1024/1024) tablespace_size, sum(decode(MAXBYTES,0,bytes/1024/1024/1024,MAXBYTES/1024/1024/1024)) max_tablespace_size
from dba_temp_files group by tablespace_name) a,
(select x.TABLESPACE tablespace_name,sum(x.blocks*y.block_size/1024/1024/1024) used_space from v$sort_usage x , dba_tablespaces y where x.tablespace=y.tablespace_name group by x.TABLESPACE) b
where a.tablespace_name=b.tablespace_name (+);
當在Oracle運行正常工作。當我嘗試從java執行查詢時,我得到「錯誤的sql語法」。
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select a.tablespace_name,a.tablespace_size Allocated_space_IN_GB, round(b.Used_space,2) Used_Space_in_GB, round(b.Used_space*100/a.tablespace_size,2) "Used%", a.max_tablespace_size MAX_tablespace_size_IN_GB ,round(b.used_space*100/a.max_tablespace_size,2) "Max_Alloc_Used%" from (select tablespace_name,sum(bytes/1024/1024/1024) tablespace_size, sum(decode(MAXBYTES,0,bytes/1024/1024/1024,MAXBYTES/1024/1024/1024)) max_tablespace_size from dba_temp_files group by tablespace_name) a, (select x.TABLESPACE tablespace_name,sum(x.blocks*y.block_size/1024/1024/1024) used_space from v$sort_usage x , dba_tablespaces y where x.tablespace=y.tablespace_name group by x.TABLESPACE) b where a.tablespace_name=b.tablespace_name (+)]; nested exception is java.sql.SQLException: ORA-00942: table or view does not exist
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
我在想什麼?
顯示java代碼。 – piokuc
向我們展示了關於java代碼... –
您應該停止在where語句的隱式連接中使用(不建議使用)的Oracle特定外連接運算符'(+)'並使用'OUTER JOIN'開始使用顯式連接運營商 –