Running Stored Procedure Error [message #155358] |
Sat, 14 January 2006 07:24 |
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
|
|
|
|
|
|