Home » Developer & Programmer » JDeveloper, Java & XML » Running Stored Procedure Error
Running Stored Procedure Error [message #155358] Sat, 14 January 2006 07:24 Go to next message
mentalray01
Messages: 22
Registered: October 2005
Junior Member
Hello.
I've a question, i was going through to invoke a Java Program from PL/SQL. Here is the Java Program


import java.sql.*;
import oracle.jdbc.* ;

public class EmpManager
{
//Add an employee in the database
public static void addEmp( int emp_id, String emp_f_name,
String emp_l_name, float emp_salary, int dept_id )
{
System.out.println("Creating new employee....");

try
{

String serverName = "127.0.0.1";
String portNumber = "1521";
String sid = "demo";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "system";
String password = "demo123";
Connection connection = DriverManager.getConnection(url, username, password);

// Connection conn=
// DriverManager.getConnection("jdbc:default:connection:");

String sql =
"INSERT INTO emp" +
"(emp_id,emp_f_name,emp_l_name,emp_salary,dept_id)"+
"VALUES(?,?,?,?,?)";

PreparedStatement p = connection.prepareStatement(sql);
p.setInt( 1, emp_id );
p.setString(2, emp_f_name);
p.setString(3, emp_l_name);
p.setFloat( 4, emp_salary );
p.setInt( 5, dept_id);
p.executeUpdate();
p.close();
}

catch( SQLException e )
{
System.err.println("Error Adding Employee:"+e.getMessage());
}
}
}




I loaded it as a procedure and set the DMBSSERVEROUTPUT to on too
but when i run the program to insert the EMP Structure, it is giving the following error.


SQL> EXECUTE add_emp( 1, 'Joe','Smith',4000.00,1);
Creating new employee....
java.security.AccessControlException: the Permission (java.net.SocketPermission
127.0.0.1:1521 connect,resolve) has not been granted to SYSTEM. The PL/SQL to
grant this is dbms_java.grant_permission( 'SYSTEM',
'SYS:java.net.SocketPermission', '127.0.0.1:1
521', 'connect,resolve' )
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:280
)
at java.security.AccessController.checkPermission(AccessController.java:419)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:544)
at
oracle.aurora.rdbms.SecurityManagerImpl.checkPermission(SecurityManagerImpl.java
:250)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1046)
at java.net.Socket.connect(Socket.java:420)
at java.net.Socket.connect(Socket.java:376)
at java.net.Socket.<init>(Socket.java:291)
at java.net.Socket.<init>(Socket.java:119)
at oracle.net.nt.TcpNTAdapter.connect(Unknown Source)
at oracle.net.nt.ConnOption.connect(Unknown Source)
at oracle.net.nt.ConnStrategy.execute(Unknown Source)
at oracle.net.resolver.AddrResolution.resolveAndExecute(Unknown Source)
at oracle.net.ns.NSProtocol.establishConnection(Unknown Source)
at oracle.net.ns.NSProtocol.connect(Unknown Source)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:898)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:233)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:372)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)
at
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:568)
at java.sql.DriverManager.getConnection(DriverManager.java:551)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at EmpManager.addEmp(EmpManager:22)
BEGIN add_emp( 1, 'Joe','Smith',4000.00,1); END;

*
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.security.AccessControlException: the Permission (java.net.SocketPermission
127.0.0.1:1521 connect,resolve) has not been granted to SYSTEM. The PL/SQL to
grant this is dbms_java.grant_permission( 'SYSTEM',
'SYS:java.net.SocketPermission', '127.0.0.1:1521', 'connect,resolve' )
ORA-06512: at "SYSTEM.ADD_EMP", line 1
ORA-06512: at line 1


Please can someone help me how to debug this error?
Waiting for an answer
Sincerely,
Ben
Re: Running Stored Procedure Error [message #155585 is a reply to message #155358] Tue, 17 January 2006 08:03 Go to previous messageGo to next message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
I don't know anything about running java stored procedures, but I would start by running the plsql line that the error message tells you to run.
Re: Running Stored Procedure Error [message #239974 is a reply to message #155358] Wed, 23 May 2007 15:30 Go to previous messageGo to next message
jungle
Messages: 6
Registered: May 2007
Junior Member

Hi,
just simply read the error message.
You have to grant some permissions executing the command shown in the error message.

Jungle
Re: Running Stored Procedure Error [message #240031 is a reply to message #239974] Wed, 23 May 2007 23:59 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Wow. Let's hope he solved it by now and leave this thread rest..
Previous Topic: Deleting a Element/Node in a XML document From PL/SQL
Next Topic: using setObject to store java objects in Oracle
Goto Forum:
  


Current Time: Sat Dec 10 08:47:00 CST 2016

Total time taken to generate the page: 0.10865 seconds