I took your code and got it to run with a couple of minor changes:
My Array TYPE object is this:
create or replace
TYPE TBL_ARRAY_VARCHAR2 AS TABLE OF VARCHAR2(80);
My code looks like this:
try {
Connection con;
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(
"jdbc:oracle:thin:@myhost:1521:LX1120", user,
password);
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
"TBL_ARRAY_VARCHAR2", con);
ARRAY array = new ARRAY(arrayDescriptor, con, new String[] { "1",
"2", "3" });
Object oArray = array.getArray();
System.out.println(oArray.getClass().getName());
if (oArray instanceof String[]) {
String[] oArrayString = (String[]) oArray;
for (int i = 0; i < oArrayString.length; i++) {
System.out.println(i + ":" + oArrayString[i]);
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
What I see when I run it is this:
[Ljava.lang.String;
0:1
1:2
2:3
So there's nothing wrong what what you are trying to do...
My guess - based on working with lots of different versions of Oracle and different Oracle JDBC drivers - is that you have a mismatch between your JDBC driver version and your database version, but that's just a guess. If I were you I'd copy the JDBC driver from the server and try again. Note that the contents of the driver can change even though the name doesn't, so comparing names is not all you need to do.
David Rolfe