Damian
Damian

Reputation: 211

Oracle Database 12c - can't compile class with method witch uses org.oracle.BLOB object

I want to invoke my Java class into Oracle Database 12c and then create the function based on my class.

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "Test" AS
import oracle.sql.*;
import java.sql.SQLException;
public class Test {
  public static String readFromBLOB(BLOB inputBLOB, int addID) throwsSQLException {    
    //some code
  }
}

CREATE OR REPLACE FUNCTION READ_BLOB(inputBLOB in BLOB, addID in number) return number
AS LANGUAGE JAVA NAME 'Test.readFromBLOB(oracle.sql.BLOB, java.lang.int) return java.lang.String';

I'm trying to create PL/SQL function based on my Test.readFromBLOB(), but compiler says:

"Error: Note: Recompile with -Xlint:deprecation for details."

Before that I used

import java.sql.*;

instead of

import oracle.sql.*;

and my class and my PL/SQL function created correctly, but when I tried to run that function then I have got an error:

ORA-29531: brak metody readFromBLOB w klasie Test
ORA-06512: przy "SYS.READ_COMMENT", linia 1
ORA-06512: przy linia 12
29531. 00000 -  "no method %s in class %s"
*Cause:    An attempt was made to execute a non-existent method in a Java class.
*Action:   Adjust the call or create the specified method.

I read a lot about it and I know that the issue is caused by Oracle Database which uses BLOB type which in Java is oracle.sql.BLOB, but this type in Java is deprecated. Earlier with java.sql.Blob the problem was that PL\SQL passed to my function oracle.sql.BLOB when my function was accept java.sql.Blob. I don't know what to do. I hope anybody helps me :)

Upvotes: 1

Views: 823

Answers (1)

Sal
Sal

Reputation: 1317

Use oracle.jdbc.OracleBlob instead.

Upvotes: 1

Related Questions