File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Passing VARRAYS to Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Passing VARRAYS to Java" Watch "Passing VARRAYS to Java" New topic

Passing VARRAYS to Java

Mark Jutras

Joined: Aug 01, 2001
Posts: 23
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.
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

Joined: Jul 31, 2003
Posts: 1
I thought the type OracleArray represents not a real Array but a ResultSet?!?!?
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
here is an example
I agree. Here's the link:
subject: Passing VARRAYS to Java
It's not a secret anymore!