This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
wood burning stoves
 
subject: Passing VARRAYS to Java
 
Similar Threads
Help! Need to write out a amount after string has certain values in it. Must add and read file.
Issue with entering data from Java class file to Database
passing array of objects from oracle stored procedure to java ...Error
Size limit in OracleCallableStatement setARRAY
local variables in the catch statement