I have the following:
def getIds(name: String): java.sql.Array = { val ids: Array[Integer] = Array() val ps: PreparedStatement = connection.prepareStatement("SELECT id FROM table WHERE name = ?") ps.setString(1, name) val resultSet = ps.executeQuery() while(resultSet.next()) { val currentId = resultSet.getInt(1) ids: currentId } return connection.createArrayOf("INTEGER", ids.toArray) }
My intention is to use the output of this method into another PreparedStatement, using .setArray(1,
But I get the following error: java.sql.SQLFeatureNotSupportedException
I'm using MySQL. Already tried INTEGER, INT, BIGINT. But all failed.
The translated content is:
After research, we found:
So my solution is to create a temporary table containing only the ids:
Then do an inner join with other statements/queries to achieve the same result: