title: Passing Scala Option[List[_]] to Java JDBC Array using statement.setArray()
body: <p>I'm trying to build an interface from Scala to JDBC callableStatements. For the most part, it's straightforward, except for <code>Lists</code>.</p>
  
  <p>I need to be able to take a Scala <code>List</code> of some type, and convert it into a Java Array that can be passed to <code>statement.setArray(type, array)</code> and I'm not having any luck (partly because I don't know Java and JDBC very well).</p>
  
  <p>Here's what I'm trying to do:</p>
  
  <pre><code>for (parameter &lt;- ps.parameters) {
      case GPArrayIn(None, t) =&gt; callableStatement.setNull(index, t)
      case GPIn(v: Some[_], Types.INTEGER) =&gt; callableStatement.setInt(index, v.get.asInstanceOf[Int])
      case GPIn(v: Some[_], Types.VARCHAR | Types.LONGVARCHAR) =&gt; callableStatement.setString(index, v.get.asInstanceOf[String])
      case GPArrayIn(v: Some[List[_]], Types.INTEGER) =&gt; callableStatement.setArray(Types.INTEGER, ???? )
      case GPArrayIn(v: Some[List[_]], Types.VARCHAR | Types.LONGVARCHAR) =&gt; callableStatement.setArray(Types.VARCHAR, ???? )
      ...
  </code></pre>
  
  <p>It's pretty straightforward for simple values but when it comes to the <code>setArray()</code> calls I'm stuck.</p>
  
  <p>Any advice would be sorely appreciated. Been stuck on this for <em>hours...</em></p>