title: How to use question mark PreparedStatement (Java)?
body: <p>I want to create a java source object in oracle database via JDBC, <code>PreparedStatement</code>. However, in the java source file, there are several question marks. Once I executed it, I faced an error message like below..</p>
  
  <pre><code>java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0).
  </code></pre>
  
  <p>I changed my code to be more understandable.</p>
  
  <pre><code>private void installOS_COMMAND() {
          Connection targetDBconn = null;
          PreparedStatement pstmt = null;
          Statement stmt = null;
  
          try {
              String SQL = "create or replace java source named \"FILE_TYPE_JAVA\" as\n"
                      + "public class FileType {\n"
                      + "    public static String getFileTypeOwner(Connection con) throws Exception {\n"
                      + "    String sFileTypeOwner = null;\n"
                      + "    CallableStatement stmt = con.prepareCall(\"begin dbms_utility.name_resolve(?,?,?,?,?,?,?,?); end;\");\n"
                      + "    stmt.setString(1, \"FILE_TYPE\");\n"
                      + "    stmt.setInt(2, 7);\n"
                      + "    stmt.registerOutParameter(3, java.sql.Types.VARCHAR);\n"
                      + "    stmt.registerOutParameter(4, java.sql.Types.VARCHAR);\n"
                      + "    stmt.registerOutParameter(5, java.sql.Types.VARCHAR);\n"
                      + "    stmt.registerOutParameter(6, java.sql.Types.VARCHAR);\n"
                      + "    stmt.registerOutParameter(7, oracle.jdbc.OracleTypes.NUMBER);\n"
                      + "    stmt.registerOutParameter(8, oracle.jdbc.OracleTypes.NUMBER);\n"
                      + "    stmt.execute();\n"
                      + "    sFileTypeOwner = stmt.getString(3);\n"
                      + "    stmt.close();\n"
                      + "    return sFileTypeOwner;\n"
                      + "  }\n"
                      + "}";
              targetDBconn = globalTargetConn.connect();
              pstmt = targetDBconn.prepareStatement(SQL);
              pstmt.executeUpdate();
          } catch (SQLException ex) { logWriter.writeLogs(logTextArea, LogWriter.ERROR, ex.getMessage());
          } finally {
              if (pstmt != null ) try {pstmt.close();} catch(SQLException ex) {}
              if (targetDBconn != null ) try {targetDBconn.close();} catch(SQLException ex) {}
          }
      }
  </code></pre>
  
  <p>Is there someone who can fix this problem?</p>