Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing VARRAYS to Java

 
Mark Jutras
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a varray holding oracle objects that I'm
trying to pass into a java method
I keep getting a ClassCastException when trying to
use getArray(). Here is my code. Thanks
in advance for any help at all.
Mark
import oracle.sql.*;
import java.sql.*;
import javax.sql.*;
import oracle.jdbc.driver.*;
import java.util.*;
import java.util.Map;
public class Arsdata{

// private static String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";

public static String Getdata(oracle.sql.ARRAY v_Header, oracle.sql.ARRAY v_Detail)
throws ClassNotFoundException, SQLException{
String returnStr = new String("Test String: ");
try {

oracle.sql.ARRAY h_array = (oracle.sql.ARRAY) v_Header.getArray();



Object[] headerObj = (Object[]) v_Header.getOracleArray();

// Each array element is mapped to ARSHeaderClass object.

for (int i=0; i < headerObj.length; i++)
{
ARSHeaderClass arsHeader = (ARSHeaderClass) headerObj[i];
// returnStr = returnStr + arsHeader.serviceorderid + ", ";
} // end for loop.

} catch (Exception e) {
System.out.println("Dealt with " + e);
returnStr = returnStr + e;

}

finally {
return returnStr;
} // end try,catch,finally block.
}
}

------------------
 
Tobias Kastl
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the type OracleArray represents not a real Array but a ResultSet?!?!?
Greetings,
rockster
 
SJ Adnams
Ranch Hand
Posts: 925
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic