Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException

User_COP0AMar 28 2020 — edited Mar 28 2020

Hi,

im trying to call java method from oracle procedure but i got the above error,the below is my java code:

DROP JAVA SOURCE AML_CONNECT."DirList";

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED AML_CONNECT."DirList" as import java.io.*;

   import java.sql.*;

  public class DirList {

   public static void getList(String directory)

throws SQLException {

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

        String sql = "INSERT INTO DIR_LIST values (?)";

         File path = new File(directory);

        String[] list = path.list();

       String element;

       for (int i = 0; i < list.length; i++) {

              element = list[i];

               PreparedStatement pstmt = conn.prepareStatement(sql);

               pstmt.setString(1, element);

               pstmt.executeUpdate();

               pstmt.close();

        }

         }

   }

/

and the below is my procedure:

create or replace PROCEDURE P_CALL_JAVA(P_DIR varchar2)

  

   as language java

    name 'DirList.getList(java.lang.String)';

also i coonest as sys to db and execute the below:

begin

  dbms_java.grant_permission(

           grantee => 'AML_CONNECT',

           permission_type=> 'SYS:java.io.FilePermission',

           permission_name=>  '<<ALL FILES>>',

            permission_action=>'execute',

           key=>x);

dbms_java.grant_permission('AML_CONNECT',

'java.util.PropertyPermission',

'*',

'read,write');

dbms_java.grant_permission('AML_CONNECT',

'java.io.FilePermission',

'\matt1.gif',

'read');

any help regarding this issue.

commit;

end;

Comments

Processing

Post Details

Added on Mar 28 2020
1 comment
374 views