我在Oracle數據庫的存儲過程是這樣的:在連接Oracle數據庫的Java
CREATE OR REPLACE PROCEDURE PSTATISTIC
AS
BEGIN
UPDATE PLACE_STATISTIC
SET POPULARITY = 0;
UPDATE PLACE_STATISTIC
SET POPULARITY = POPULARITY + 1
WHERE PLACE_ID IN (SELECT PLACE_COMMENT.PLACE_ID
FROM PLACE_COMMENT);
END PSTATISTIC;
當我把它稱爲對SQL開發人員:
EXECUTE PSTATISTIC
它執行通常,PLACE_STATISTIC
表已更新
但是,當我試圖在Java上使用它時:
String sql="EXECUTE HR.PSTATISTIC";
Statement statement=(Statement)connectionDB.createStatement();
statement.execute(sql);
它沒有Java的工作了,理由是這類錯誤的:
java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:194)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1000)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1882)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1847)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:301)
我如何可以執行Java的我PSTATISTIC
程序?我授予的所有必要的權限
請參閱http://www.coderanch.com/t/568116/JDBC/databases/Oracle-procedure-works-direct-SQL –