title: Callablestatement error : Missing IN or OUT parameter at index:: 1
body: <p>I am trying to run Oracle's <strong>CREATE JAVA</strong> statement.</p>
  
  <p>We have had to set CallableStatement.setEscapeProcessing to false to avoid troubles with question marks. This works fine for most of our statements, but in the case of a Java switch statement, we are getting the exception below :</p>
  
  <pre>
  
  java.sql.SQLException: Missing IN or OUT parameter at index:: 1
  
  </pre>
  
  <p>I suppose it has something to do with the colons used in the switch statement.</p>
  
  <p>Here's an example of the problem :</p>
  
  <p><strong>JDBCTest.java</strong></p>
  
  <pre><code>package jdbctest;
  
  import java.io.BufferedReader;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.sql.CallableStatement;
  import java.sql.Connection;
  import java.sql.DriverManager;
  
  public class JDBCTest {
  
      public static void main(String[] args) throws Exception {
          String data = readScript("/tmp/Demo.sql");        
  
          Connection conn = null;
          CallableStatement callStat = null;
          try {
              String driver = "oracle.jdbc.driver.OracleDriver";
              String url = "jdbc:oracle:thin:@193.53.40.220:1521:ora11";
              String username = "";
              String password = "";
  
              Class.forName(driver);
              conn = DriverManager.getConnection(url, username, password);
              conn.setAutoCommit(false);
              callStat = conn.prepareCall(data);
              callStat.setEscapeProcessing(false);
              callStat.execute();
          } finally {
              try {callStat.close();} catch (Exception ex){}
              try {conn.close();} catch (Exception ex){}
          }
  
      }
  
      private static String readScript(String filename) throws IOException
      {
          StringBuilder stringBuilder = new StringBuilder();
          BufferedReader reader = null;
          try {
              String currentLine;
              reader = new BufferedReader(new InputStreamReader(
                      new FileInputStream(filename), "ISO-8859-1"));
  
              while ((currentLine = reader.readLine()) != null) {
                  currentLine = currentLine.replaceAll("^\\s+$", "");
                  currentLine = currentLine.replaceAll("\\s+$", "");
                  stringBuilder.append(currentLine).append("\n");
              }
          } finally {
              try { reader.close();} catch (Exception ex) {}            
          }
  
          return stringBuilder.toString();
      }
  
  }
  </code></pre>
  
  <p><strong>Demo.sql</strong></p>
  
  <pre><code>CREATE OR REPLACE JAVA SOURCE NAMED "jdbctest" AS
  
  package jdbctest;
  
  public class Demo {
      public void test()
      {
          int a = 3;
          switch (a)
          {
              case 1: System.out.println("1"); break;
              case 2: System.out.println("2"); break;
              case 3: System.out.println("3"); break;
          }
      }
  }
  </code></pre>
  
  <p>This was run using ojdbc6.jar (as the JDBC driver) on a 11gR2 Oracle database.</p>