• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Stored Procedure to execute exp.exe for taking BACKUPS  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using JAVA Stored Procedures, to execute the Oracle EXP.exe utility for taking backups.
My JAVA source file is like this:
----------------------------------------------------------
import java.io.*;
import java.util.*;
import java.security.*;

public class Hello
{
public static void printHello ()
{
String prtString="Hello World";
System.out.println(prtString);
}
public static void backup()
{
try
{
System.out.println("Backup Start");
String exp []= {"EXP.exe","HR/HR","GRANTS=Y","TABLES=(EMPLOYEES)"};
Runtime.getRuntime().exec(exp);
System.out.println("Backup End");
}
catch (IOException ioe)
{
System.out.println("IO Exception Caught: " +ioe.getMessage());
}
catch (AccessControlException ace)
{
System.out.println("Access Control Exception Caught: " +ace.getMessage());
}
catch (Exception e)
{
System.out.println("Exception Caught: " +e.getMessage());
}
}
}
----------------------------------------------------------
and i have made two procedure to publish my JAVA Procedures that those are:
----------------------------------------------------------
CREATE OR REPLACE PROCEDURE printHello
AS LANGUAGE JAVA
NAME 'Hello.printHello()';
/
CREATE OR REPLACE PROCEDURE backup
AS LANGUAGE JAVA
NAME 'Hello.backup()';
/
----------------------------------------------------------
I am executing these procedures like this:
----------------------------------------------------------
SQL> call printHello();
Hello World
Call completed.
SQL> call backup();
Backup Start
Access Control Exception Caught: the Permission (java.io.FilePermission <<ALL
FILES>> execute) has not been granted to HR. The PL/SQL to grant this is
dbms_java.grant_permission( 'HR', 'SYS:java.io.FilePermission', '<<ALL FILES>>',
'execute' )
Call completed.
----------------------------------------------------------
I am getting this File Permission exception on executing backup() procedure. I don't know how to solve the problem, i have try the method "dbms_java.grant_permission( 'HR', 'SYS:java.io.FilePermission', '<<ALL FILES>>',
'execute' )" but the issue remains there.
One more thing, I have executed the "backup()" method using JDK, its working but when i try this on ORACLE JVM the exception is thrown.
Waiting for your comments, and if you have other solution please tell me.
Thank you,
Jawed Nazar Ali
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!