Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem may be that you have not grant java permissions to the code. see ORADOC / packet SYS.JAVA_PERMISSION
For socket java stuff i use something like that.
begin
dbms_java.grant_permission('<Schemaname>',
'java.net.SocketPermission',
'*',
'accept, connect, listen, resolve');
commit;
end;

you have to grant as user SYSTEM and logout.
copy from one website
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic