Why not simple use java.sql.Connection.createArrayOf(). We can have one prepere statment https://stackoverflow.com/questions/50083516/jdbc-createarrayof-from-arraylist