Is it possible to call sql function via prepared Statement in java?

  • 0
    Through pgAdmin, I created a function for my database, can I create a request on the server using preparedStatement to call this function, that is, pass it the following line as an argument:
    private static final String SQL_FUNC_REQUEST = "Select addNode(?, xmlelement(name action, xmlattributes('? as billId, 
    ? as name), \n" +
                "\t\t\t\t\t\t\t xmlelement(name status, ?)));";
    PreparedStatement preparedStatement = connection.prepareStatement(SQL_FUNC_REQUEST)

    My function has the following signature:
    create or replace function addNode(xmlId integer, newNode xml)
    returns void as ...

    That is, he will also see this function after it has been created, do I understand correctly?
    Java Anonymous, Apr 25, 2019

  • 1 Answers
  • 0
    Use the CallableStatement interface to call functions.
    Adrian Ochoa

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!