This discussion is archived
3 Replies Latest reply: Mar 5, 2013 3:33 AM by Mihael RSS

create java procedure using jdbc

kamilp Newbie
Currently Being Moderated
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:

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points