I am trying to insert a series of values into a sql query using Java's postgresql jdbc4.
java.sql.Connection
specifies a method to convert Object[]
into java.sql.Array
: conn.createArrayOf(String typeName, Object[] elements)
The only problem is, no matter what I try, it always returns null.
public Array makeQueryBigintArray(Object[] values) throws SQLException {
Array result = conn.createArrayOf("bigint", values);
// "result" is null at this point, but shouldn't be
return result;
}
conn
is retrieved through a working javax.sql.DataSource
via dataSource.getConnection()
. conn
works for all our other database uses, but its createArrayOf()
method always returns null.
I have tried both upper case "BIGINT" and lower case "bigint" for typeName, as per this question, to no avail.
When I dig through the debugger, I find that conn
is a org.apache.commons.dbcp.PoolableConnection
wrapping a org.postgresql.jdbc4.Jdbc4Connection
.
If the feature wasn't supported by postgres/JDBC4, I would expect calling it to throw a SQLException indicating it's unsupported. No exception is thrown.
Any clue as to why it's returning null?
How can I fix it, or else, how can I pass in an array or List of values to a PreparedStatement
?