title: Getting the Return Value from JDBC MSSQL
body: <p>I'm connecting to SQL Server (2005) through Java using the Microsoft SQL Server JDBC Driver 2.0. </p>
  
  <p>How do I get the return value from a stored procedure? I'm doing something like:</p>
  
  <pre><code>Connection connection = dataSource.getConnection()
  CallableStatement proc = connection.prepareCall("{ call dbo.mySproc() }");
  proc.execute();
  </code></pre>
  
  <p>Should I be using execute()? executeQuery()? executeUpdate()? None of these seem to return a return value by default but I'm not really sure how to get to it.</p>
  
  <p>EDIT 1: To be clear, I know how to call stored procedures. This question is specifically about how to get the RETURN VALUE (as opposed to a Result Set). The Return Value is an integer that is usually generated when you execute a query with no Result Set or if you specifically state something like <code>RETURN 0</code> in your SQL.</p>
  
  <p>EDIT 2: executeUpdate() returns an int but this int is not the same as the Return Value. Also, an OUT parameter is not the same as a return value.</p>