3 Replies Latest reply: Mar 5, 2013 5:33 AM by Mihael RSS

    create java procedure using jdbc

    kamilp
      Hi,
      I am trying to create java procedure using jdbc connection, I am using Oracle 11.2. When I create the procedure using sqlplus it works fine. Using jdbcit fails; code sniplet below:


                     ddl =
                     "create or replace java source named \"UTLCMD\" as \r\n"+
                     "import java.lang.Runtime; \r\n"+
                     "public class execHostCommand \r\n"+
                     "{ \r\n"+
                     "public static void execute (String command) \r\n"+
                     " throws java.io.IOException \r\n"+
                     " { \r\n"+
                     " Runtime rt = java.lang.Runtime.getRuntime(); \r\n"+
                     " rt.exec(command); \r\n"+
                     " } \r\n"+
                     "}";

                     statement = conn.createStatement();
                     statement.executeUpdate(ddl);


      I am getting this error:

      2013-01-26 12:45:31.835 UTC: ERROR: Exception "java.sql.SQLException: ORA-29536: badly formed source: Encountered "ublic" at line 3, column 1.
      Was expecting one of:
      "extends" ...
      "implements" ...
      "{" ...
      "<" ...

      ". Stack dump: