GeeCON Prague 2014*
The moose likes JDBC 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
Bookmark "Passing VARRAYS to Java" Watch "Passing VARRAYS to Java" New topic
Author

Passing VARRAYS to Java

Mark Jutras
Greenhorn

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.
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

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

Joined: Sep 28, 2001
Posts: 925
http://www.coderanch.com/t/79966/Oracle-OAS/pass-two-dimensional-Object-Array
here is an example
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing VARRAYS to Java