Home » Developer & Programmer » JDeveloper, Java & XML » Java Stored Procedure sending UDP message
Java Stored Procedure sending UDP message [message #91596] Wed, 04 December 2002 07:29 Go to next message
Alapalaya
Messages: 1
Registered: December 2002
Junior Member
Hi everybody,

I'm trying to write a Java Stored Procedure in Oracle 8.1.7, to be used inside a trigger, sendind a notification message via UDP broadcast.

It seems to me that there is no way to grant a permission (SocketPermission), so that the message can be sent (all the available permissions are liste,resolve,accept,connect).

This is the code of the Java class I would like to use:

-------------------------------------------
import java.lang.*;
import java.io.*;
import java.net.*;
import java.util.*;

public class UdpSendMessage {
public static void UDPBroadcast(String hostname, String strport, String message) throws IOException {

DatagramSocket socket = new DatagramSocket();

String str = message;
byte[[]] buf = new byte[[256]];
buf = str.getBytes();

int port = Integer.parseInt(strport);

InetAddress address = InetAddress.getByName(hostname);
DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);

// HERE THE ERROR!!!
socket.send(packet);

socket.close();

System.out.println("Sent: '" + str + "' sent to host '" + address.getHostName() + ":" + port + "'");
}
}
-------------------------------------------

all works fine as long as the "socket.send(packet)" is commented out (which makes the procedure useless); otherwise I have:

ORA-29532: chiamata Java terminata a causa di un'eccezione Java non ottenuta:
java.net.SocketException: sendto failed, errno = 10013
An attempt was made to access a socket in a way forbidden by its access
permissions.

ORA-06512: a "TEST.UDPSENDMESSAGE", line 0
ORA-06512: a line 1

Can anyone please help me?

TIA.
Re: Java Stored Procedure sending UDP message [message #91603 is a reply to message #91596] Fri, 06 December 2002 09:51 Go to previous message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
first try to compile and execute ur code as java standalone.
then 
1. Logon as SYS 
2. issue the following commands :     
   
   call dbms_java.grant_permission('user','java.net.SocketPermission','*','connect,resolve');    
   commit;       --****MUST****
   call dbms_java.grant_permission('user','java.util.PropertyPermission','*','read,write'); 
   commit;	 --****MUST****
3. try to compile/execute ur java stored procedure

Previous Topic: how to insert large value in CLOB field
Next Topic: Shared memory realm not exists
Goto Forum:
  


Current Time: Tue Jul 27 15:46:22 CDT 2021