0
我在使用JDBC調用PostgreSQL函數時遇到問題,情況如下。存儲功能endpoint_organizations
的定義是這樣的:通過JDBC執行PostgreSQL存儲函數時出現異常「函數不存在」
postgres=# \df public.endpoint_organizations
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+------------------------+------------------------------------------+---------------------+--------
public | endpoint_organizations | TABLE(organizationid integer, name text) | staffid1 integer | normal
(1 row)
我從Java調用它是這樣的:
int staffId = 1
PreparedStatement endpointOrganizations = connection.prepareStatement("SELECT * FROM endpoint_organizations (?)");
endpointOrganizations.setInt(1, staffId);
ResultSet resultSet = endpointOrganizations.executeQuery();
我收到此異常:
org.postgresql.util.PSQLException:
ERROR: function endpoint_organizations(integer) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 15
可能是什麼原因?如果我沒有弄錯,那以前就行得通了。我現在已經重複檢查和三重檢查,但沒有看到可能導致問題的原因。
您是否有權限使用jdbc用戶執行該功能?如果不授予對功能endpoint_organizations的執行; – d1ll1nger
@ d1ll1nger是的,我有。如果我'psql -U'到數據庫中並且'select * from endpoint_organizations(1)'那裏,事情工作正常。 –
Drux