title: How to call Sybase stored procedure with named params using JDBC
body: <p>I have a stored procedure in Sybase which I can invoke from my favourite SQL client like this:</p>
  
  <pre><code>exec getFooBar @Foo='FOO', @Bar='BAR'
  </code></pre>
  
  <p>It returns a table of results, so its like a query. It has actually many parameters, but I only want to call it with Foo and sometimes with Foo and Bar specified.</p>
  
  <p>Sybase is ASE 15.0, I am using jConnect 6.0.5.</p>
  
  <p>I can invoke this using a <code>PreparedCall</code> if I specify only the first parameter:</p>
  
  <pre><code>CallableStatement cs = conn.prepareCall("{call getFooBar(?) }");
  cs.setString(1,"FOO");
  </code></pre>
  
  <p>However I can't use the <code>@Foo</code> notation to pass my params:</p>
  
  <pre><code>conn.prepareCall("{call getFooBar @Foo='FOO' }");
  conn.prepareCall("call getFooBar @Foo='FOO' ");
  conn.prepareCall("{call getFooBar @Foo=? }"); // + setString(1,'FOO')
  </code></pre>
  
  <p>In all these cases I get exception from the DB telling me that the Foo parameter is expected:</p>
  
  <pre><code>com.sybase.jdbc3.jdbc.SybSQLException: Procedure getFooBar expects
  parameter @Foo, which was not supplied
  </code></pre>
  
  <p>Ideally I'd like to do this with Spring <code>JdbcTemplate</code> or <code>SimpleJdbcCall</code>, but with those I could not even get to the point where I could with plain old JDBC.</p>
  
  <p>So to summarize, I'd like to avoid ending up with:</p>
  
  <pre><code>{ call getFooBar(?,null,null,null,null,null,?,null,null) }
  </code></pre>
  
  <p>Is that possible using JDBC or better Spring?</p>