|
Need Help call Java Programm from PLSQL [message #671069 is a reply to message #671038] |
Mon, 13 August 2018 23:41 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.gravatar.com/avatar/233e16ea804014f5dd6b5db2cff5ff7f?s=64&d=mm&r=g) |
MUKESH_ALTEC
Messages: 3 Registered: August 2018
|
Junior Member |
|
|
Dear All,
I have a Java Program which shows the List of Ports available in my system.
This program running fine at Command Prompt. But Now i want to use this Java program through PL/SQL.
I have Successfully Loaded Java Source and Java Class in Oracle.
Both Java Source and Java Class Status showing Valid in User_Obejcts Table.
But Unable to Call this from PLSQl
Spend Lot of time But can't Success.
Here is My PlSQL programm
CREATE OR REPLACE procedure TestPorts_PROC
AS LANGUAGE JAVA
NAME 'TestPorts.main(java.lang.String[])';
Error Showing
"exec TestPorts_PROC;
BEGIN TestPorts_PROC; END;
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NullPointerException: name can't be null
ORA-06512: at "HR1.TESTPORTS_PROC", line 1
ORA-06512: at line 1
"
Below is my Java Program.
import javax.comm.*;
import java.util.*;
/** List all the ports available on the local machine. **/
public class TestPorts
{
public static void main (String args[])
{
Enumeration port_list = CommPortIdentifier.getPortIdentifiers();
while (port_list.hasMoreElements())
{
CommPortIdentifier port_id = (CommPortIdentifier)port_list.nextElement();
if (port_id.getPortType() == CommPortIdentifier.PORT_SERIAL)
{
System.out.println ("Serial port: " + port_id.getName());
}
else if (port_id.getPortType() == CommPortIdentifier.PORT_PARALLEL)
{
System.out.println ("Parallel port: " + port_id.getName());
}
else
System.out.println ("Other port: " + port_id.getName());
}
} // main
} // class PortList
[Updated on: Tue, 14 August 2018 00:08] Report message to a moderator
|
|
|
|
|
|
Re: Need Help call Java Programm from PLSQL [message #671108 is a reply to message #671085] |
Wed, 15 August 2018 11:03 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](http://www.orafaq.com/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68675 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
SQL> CREATE OR REPLACE procedure TestPorts_PROC
2 AS LANGUAGE JAVA
3 NAME 'TestPorts.main(java.lang.String[])';
4 /
SQL> exec TestPorts_PROC;
BEGIN TestPorts_PROC; END;
*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NullPointerException: name can't be null
ORA-06512: at "HR1.TESTPORTS_PROC", line 1
ORA-06512: at line 1
You call the procedure with no parameters when Java one takes an array, so the error, the PL/SQL procedure should has the same or equivalent parameters than the Java one.
|
|
|