How to do it...

As in the previous recipe, we will continue using the PostgreSQL database for demonstration purposes. Before writing custom SQL statements, functions, and stored procedures, you should look at the list of already existing functions first. Usually, they provide a wealth of functionality.

Here is an example of calling the replace(string text, from text, to text) function that searches the first parameter (string text) and replaces it with all the substrings that match the second parameter (from text ) with the substring provided by the third parameter (string text):

String sql = "{ ? = call replace(?, ?, ? ) }";try (CallableStatement st = conn.prepareCall(sql)) {  st.registerOutParameter(1, Types.VARCHAR);  st.setString(2, "Hello, ...

Get Java 11 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.