通过 JDBC 执行 PostgreSQL 存储函数时出现异常 "function does not exist"

Exception "function does not exist" when executing PostgreSQL stored function via JDBC

我在以下情况下从 JDBC 调用 PostgreSQL 函数时遇到问题。存储函数endpoint_organizations定义如下:

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

可能是什么原因?如果我没记错的话,这以前有用过。我现在已经仔细检查和三次检查,但没有看到可能导致问题的原因。

这(当然)是我的一个愚蠢错误。在使用 psql -U <user> 而不是 psql -U <user> <database> 连接到 PostgreSQL 后,我最近也对存储函数进行了更新,即更新受影响的数据库 postgres 而不是 <database>,而 JDBC 连接到 <database>

对正确的数据库执行更新后,现在一切恢复正常。