Is it possible to send an array of integers from Java to a (SqlAnywhere16) store procedure? I get the following error.
Exception thrown :java.sql.SQLException: [Sybase][JDBC Driver][SQL Anywhere]Communication error Query: CALL spw_GetStuff(?) Parameters: [[0,1]]
My software stack is as follows :- Java – DBUtils – JDBC – network – Stored Procedure - SQLAnywhere
The call is :-
Is this possible? And if so, what am I doing wrong?
Bonus question: Can I dynamically change the size of my array or must it be hardcoded?
I know nothing about the Java's 'dbutils' package and it has been many years since I have written a Java program, but...
You cannot transfer an array from the client to the server OR from the server to the client as an ARRAY (or ROW) data type. See the documentation on composite data types for a discussion of the limitations of using ARRAY and ROW types.
If you know the length of the array - in your example this is 2 - you could pass each element in the array as a separate bound (i.e. '?') parameter in the statement (e.g. "call spw_GetStuff(?,?)").
Another option is to build a batch to construct the array and then call the procedure - something like: "begin declare @a array(2) of integer; set @a[] = ?; set @a[] = ?; call spw_GetStuff(@a); end;"
answered 18 Mar '15, 07:53