• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Stored Procedure to execute exp.exe for taking BACKUPS

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic