ARRAY array_to_pass = new ARRAY( descriptor, conn, intArray ); OraclePreparedStatement ps = (OraclePreparedStatement)conn.prepareStatement ( "begin give_me_an_array(:x); end;" ); ps.setARRAY( 1, array_to_pass ); ps.execute(); } Somehow, my company does not allow us to use any oracle extension on JDBC, and we only can use API that used in standard JDBC. But in standard JDBC, I can not find a equivalent object as oracle's ArrayDescriptor, and there is not constructor for java.sql.Array, thus I do not know how to construct an Array object in Java side.
What should I do then? Is it impossible for me to avoid oracle's extention?
"xingwogong", We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Xing, I think databases handle arrays in different ways. Just like BLOB/CLOB, there is no vendor netural class. In the case of BLOB/CLOB, there are alternative ways of setting the value (like a byte array or binary stream.)
The lack of response to this questions also indicates that nobody has done this for arrays. From the JavaDoc, it looks like the implementation of Array is very database specific.
"java.sql.Array" is an interface, not a class, and therefore has no constructor. Obviously every JDBC driver is going to implement this interface differently. Hence, as Jeanne said, there is no database-independent way to pass an array to a stored procedure. As far as I can see, you simply need to find a different way of passing an array of values to your stored procedure.