-1

There is a Postgresql database with the following function cap

CREATE OR REPLACE FUNCTION net_train(terms text[], answer integer)
  RETURNS void AS
$BODY$begin
--this code is stub
end;$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION net_train(text[], integer)
  OWNER TO postgres;

It is necessary to call this function from java program. Tell me how to do it (preferably with sample code).

user1851132
  • 341
  • 1
  • 6
  • 15

1 Answers1

1

The JDBC PostgreSQL doc contains this page, which details how to call a function using Connection.prepareCall(). It returns a CallableStatement

The interface used to execute SQL stored procedures. The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number, with the first parameter being 1.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440