Home » SQL & PL/SQL » SQL & PL/SQL » Java network problem within 10g (Oracle 10g)
icon5.gif  Java network problem within 10g [message #471976] Wed, 18 August 2010 02:18 Go to next message
yvesonline
Messages: 2
Registered: August 2010
Location: Mainz, Germany
Junior Member
Hello readers,
I have a rather hard to trace problem which is keeping me up several days now.
We want to implement a package for querying devices via SNMP in our database. There are no packages shipped with Oracle that come handy. UTL_TCP does not work because SNMP works via UDP. After all we came up with the idea to use www.snmp4j.org. Locally on my development machine and on the command line of the Oracle database our first prototype of the SNMP query function works very well, but inserted into the database all I'm getting is a "Request timed out". Firewall mechanisms can not be the problem because the java code runs smoothly on the command line and also a snmpwalk on the command line suceeds, so the database is not blocked by any firewall. First I thought some permission via Java are missing, but I took a look in the USER_JAVA_POLICY view and worked this with SYSDBA out. A java application in Oracle connection via TCP to port 80 and fetching a website works allright, the thing not working seems to be UDP. Does anyone of you have any hints on how to debug, trace such a problem?
Greets, Yves
Re: Java network problem within 10g [message #472027 is a reply to message #471976] Wed, 18 August 2010 06:59 Go to previous messageGo to next message
Alessandro Rossi
Messages: 166
Registered: September 2008
Location: Rome
Senior Member
First
There is a simple MAIL interface in PL/SQL!

Second
That is not the way to describe an error! Post a simple and reproducible test case if you want valid answers. The things you illustrated were not enough detailed too, so there are no many chances to find your problem using your description too!!

Bye Alessandro
Re: Java network problem within 10g [message #472028 is a reply to message #472027] Wed, 18 August 2010 07:12 Go to previous messageGo to next message
yvesonline
Messages: 2
Registered: August 2010
Location: Mainz, Germany
Junior Member
SNMP... not SMTP.
There can be no more detailled error description because it simply "times out".
I just wanted to hear if someone did the same (sending UDP over Java in Oracle) and what her/his experiences are.
Re: Java network problem within 10g [message #472035 is a reply to message #472028] Wed, 18 August 2010 08:37 Go to previous message
Alessandro Rossi
Messages: 166
Registered: September 2008
Location: Rome
Senior Member
Ok sorry for that mistake!

So now just to be clear what goes on timeout. UDP is a datagram protocol then an UDP transmission can't go on timeout.

Resource allocation may go on timeout ...but yes you can't explain your problem.



Try to see what happens with this simple test case to see if you can do networking operations.

create or replace and compile java source named UDPTry as

import java.io.*;
import java.net.*;

public class UDPTry {
	public static void send(String s,int p) throws SocketException,IOException {
		DatagramSocket ds = new DatagramSocket();
		byte[] buf = s.getBytes();
		InetAddress address = InetAddress.getByName("127.0.0.1");
		DatagramPacket packet = new DatagramPacket(buf, buf.length,address, p);
		ds.send(packet);
	}
	public static String receive(int p) throws SocketException,IOException {
		DatagramSocket ds = new DatagramSocket(p);
		byte[] buf = new byte[256];
		DatagramPacket packet = new DatagramPacket(buf, buf.length);
		ds.receive(packet);
		return new String(packet.getData(), 0, packet.getLength());
	}
}


create or replace package UDP_TRY is
	procedure send(
			string in varchar2,
			port in pls_integer
		) AS LANGUAGE JAVA NAME 'UDPTry.send(java.lang.String,int)';
	function receive(
			port in pls_integer
		) return varchar2 AS LANGUAGE JAVA NAME 'UDPTry.receive(int) return java.lang.String';
end UDP_TRY;


Then you can call the receive and send methods (in two different sessions ) to test is it works.

First session (call receive using UDP port 22 )
SQL> begin
  2     dbms_output.put_line(udp_try.receive(22));
  3  end;
  4  /


Second session (call send using UDP port 22)
begin
   udp_try.send('HELLO',22);
end;
/


In this case I noticed that on this database I don't have permission to open UDP connection on port 22.

SQL> begin
  2     dbms_output.put_line(udp_try.receive(22));
  3  end;
  4  /
begin
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.net.BindException: bind() failed, errno = 13
Permission denied
ORA-06512: at "ALESSANDRO.UDP_TRY", line 6
ORA-06512: at line 2



Bye Alessandro

[Updated on: Wed, 18 August 2010 08:55]

Report message to a moderator

Previous Topic: Refersh Views and Function
Next Topic: System table updation
Goto Forum:
  


Current Time: Fri Dec 09 07:56:39 CST 2022