I have a JDBC Prepared Statement that take a parameter of ltree[],
My goals is to query multiple entries from my_table, where the path is ltree
type and is the primary key. Performance is critical, so I’m using Prepared Statements and I don’t what to construct the query programmatically, I want to pass the list of primary keys (ltree[]
) as a parameter.
Here is my prepared Statement
PreparedStatement myStatement = connection.prepareStatement(
"""
SELECT path
FROM my_table
WHERE path IN ( ? )
""");
The code where I try to populate the parameter
ArrayList<String> listWithQuotes = new ArrayList<>();
listWithQuotes.add("A.B.C");
listWithQuotes.add("A.B");
Array array = connection.createArrayOf("ltree[]",listWithQuotes.toArray() );
currStatement.setArray(1,array);
ResultSet rs = currStatement.executeQuery();
Here is the error message I’m getting
java.lang.RuntimeException: java.lang.RuntimeException: org.postgresql.util.PSQLException: Unable to find server array type for provided name ltree[].
P. M. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.