title: Execute PL SQL with Java
body: <p>I have the following PL SQL that I am trying to run from my Java application.</p>
  
  <pre><code>SET SERVEROUTPUT ON
  DECLARE
  XMLVal  CLOB := '&lt;some xml here&gt;';
  
  Msg Varchar2(100);
  BEGIN
    mands.Lib_Interface.LoadData(Msg, XMLVal);
    DBMS_OUTPUT.PUT_LINE(Msg);
  END;
  </code></pre>
  
  <p>My java code is ----EDITED----- updated the prepareCall from</p>
  
  <pre><code>CallableStatement vStatement = vDatabaseConnection.prepareCall("begin ? := mands.Lib_Interface.LoadData(?, ?); end;");
  </code></pre>
  
  <p>to</p>
  
  <pre><code>CallableStatement vStatement = vDatabaseConnection.prepareCall("begin mands.Lib_Interface.LoadData(?, ?); end;");
  </code></pre>
  
  <hr>
  
  <pre><code>Connection vDatabaseConnection = DriverManager.getConnection(dbAddress, dbSchema,dbScemaPassword);
  CallableStatement vStatement = vDatabaseConnection.prepareCall("begin mands.Lib_Interface.LoadData(?, ?); end;");
  
  vStatement.setString(3, xml);
  vStatement.registerOutParameter( 1, Types.VARCHAR );
  vStatement.registerOutParameter( 2, Types.VARCHAR );
  vStatement.executeUpdate();
  </code></pre>
  
  <p>However when I run the code i get the following SQLException</p>
  
  <pre><code>java.sql.SQLException: ORA-06550: line 1, column 14:
  PLS-00222: no function with name 'LOADDATA' exists in this scope
  ORA-06550: line 1, column 7:
  </code></pre>
  
  <p>I have no issues when using the command with SQL Developer. </p>
  
  <p>I have googled the issue but at a loss. Any help would be appreciated. </p>
  
  <p>Regards</p>
  
  <p>Tone</p>
  
  <p>-----------------------------EDIT-------------------------</p>
  
  <p>So I have also tried </p>
  
  <pre><code>vStatement.setClob(3, new StringReader(xml));
  vStatement.registerOutParameter( 1, Types.VARCHAR );
  vStatement.registerOutParameter( 2, Types.VARCHAR );
  vStatement.execute();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Clob clob = vDatabaseConnection.createClob();
  clob.setString(1, xml);
  vStatement.setClob(3, clob);
  vStatement.registerOutParameter( 1, Types.VARCHAR );
  vStatement.registerOutParameter( 2, Types.VARCHAR );
  </code></pre>
  
  <p>but am still getting the same error.</p>
  
  <p>-----------------EDIT-----------------------</p>
  
  <p>Here is the working code</p>
  
  <pre><code>Connection vDatabaseConnection = DriverManager.getConnection("dbAddress","dbSchema","dbPassword");
  CallableStatement vStatement = vDatabaseConnection.prepareCall("begin mands.Lib_Interface.LoadData(?, ?); end;");
  
  vStatement.setClob(2, new StringReader(xml));
  vStatement.registerOutParameter( 1, Types.VARCHAR );
  vStatement.executeUpdate();
  </code></pre>