How to reuse ArrayDescriptor?

I tried the code below:

public class Abc { private ArrayDescriptor arrayDesc; void init() { connection = //create connection arrayDesc = ArrayDescriptor.createDescriptor("DBTYPE",connection); } void m1() { conn1 = //create connection ARRAY array_to_pass1 = new ARRAY( arrayDesc , conn1, idsArray1 ); } void m2() { conn2 = //create connection ARRAY array_to_pass2 = new ARRAY( arrayDesc , conn2, idsArray2 ); } } 

This code reports the error below:

table.java.sql.SQLException: Missing handle at oracle.sql.DatumWithConnection.assertNotNull (DatumWithConnection.java:103)

How can this be solved?

+5
source share
2 answers

ArrayDescriptor is deprecated. Assuming your connection objects are of type OracleConnection , try using createOracleArray - something like this:

 public class Abc { void init() { connection = //create connection } void m1() { conn1 = //create connection array array_to_pass1 = conn1.createOracleArray(arrayDesc, idsArray1); } void m2() { conn2 = //create connection array array_to_pass2 = conn2.createOracleArray(arrayDesc, idsArray2); } } 

Note. Using this method, arrays will be of type java.sql.Array , not oracle.sql.ARRAY .

+2
source

new ARRAY must be called using an ArrayDescriptor that uses the same connection. What you are trying to do will not work. Note that each connection has a descriptor cache, so the descriptor will only be created once per connection.

0
source

Source: https://habr.com/ru/post/1274806/


All Articles