Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problems when passing an array of Object to a PL/SQL stored procedure

791250Aug 13 2010 — edited Sep 1 2010
Hello everyone,

I'm currently using the oracle jdbc driver ojdbc14 on oracle 10g edition.
It's been a while i'm trying to pass an array of parameters to a PL/SQL stored procedure, using Spring's SimpleJdbcCall class. Here's how i implemented this:

Object[] parameters = new Object[2];
parameters[0] = 12345L;
parameters[1] = "sample string";

Connection connection = jdbcTemplate.getDataSource().getConnection();
Map<String, Object> inParameters = new HashMap<String, Object>();

ArrayDescriptor arraydesc = ArrayDescriptor.createDescriptor(SCHEMA_NAME + "." + ARRAY_DESCRIPTOR_NAME, connection);

Struct[] tabstruct = new Struct[] {
new STRUCT(
StructDescriptor.createDescriptor(SCHEMA_NAME + "." + STRUCT_DESCRIPTOR_NAME, connection),
connection,
parameters
)
};

ARRAY array = new ARRAY(arraydesc, connection, tabstruct);
inParameters.put(procedureParamName, array);
simpleJdbcCall.declareParameters(new SqlParameter(PROCEDURE_PARAM_NAME, Types.ARRAY));
simpleJdbcCall.execute(inParameters);

My stored procedure receives an ARRAY of STRUCT, mapped by Object[] in Java, and simply inserts parameters in database.

The result is a new entry in database, with 12345L (first parameter passed successfully) and with "null" instead of "sample string".

I found out that this problem could be caused by encoding matters, so i added orai18n.jar to my classpath, but i get the same issue.
I logged which default charset my JVM is using, and compared it to the charset of my database:
My JVM encodes String in UTF-8 format, and my database is ISO-8859-1 (WE8ISO8859P15).

I also noticed on Oracle's web site that my ojdbc driver should support UTF-8 and ISO-8859-1 (it is also recommended to use orai18n, which is what i do).

I tried to encode my String in ISO-LATIN-1 with the follwing code, but it's always the same.

try {
parameters[1] = new String("sample string".getBytes("ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
log.error(e);
}

Did anyone experience the same issue?

Thanks for help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 29 2010
Added on Aug 13 2010
5 comments
3,578 views