Re: Errors using JDBC batchUpdate with plpgsql function - Mailing list pgsql-general

From Hannes Erven
Subject Re: Errors using JDBC batchUpdate with plpgsql function
Date
Msg-id 55474A6E.30203@erven.at
Whole thread Raw
In response to Errors using JDBC batchUpdate with plpgsql function  (Nanker Phelge <n.phelge01@gmail.com>)
Responses Re: Errors using JDBC batchUpdate with plpgsql function  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
Hi,


 >          String sql = "select test_user_result_insert_func(?, ?, ?);";

You can't call functions via JDBC like that. You need to use:

CallableStatement cs = connection.prepareCall("{call func(?,?,?)}");

// Loop starts...
cs.clearParameters();
cs.setString(1, "foo");
cs.setString(2, "bar");
cs.setString(3, "baz");
cs.addBatch();
// Loop ends

cs.executeBatch();



See also: https://jdbc.postgresql.org/documentation/94/callproc.html



Best regards,

    -hannes




pgsql-general by date:

Previous
From: Anton
Date:
Subject: Re: [HACKERS] optimization join on random value
Next
From: Thomas Kellerer
Date:
Subject: Re: Errors using JDBC batchUpdate with plpgsql function