Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> 2D Array of integers
Hi there
I work on a Java application and I try to store in a table (Oracle 9i) a matrix of integers, ie a 2D array of integers.
And I can't make it work.
Here si my code :
// I have already done this on my data base :
// CREATE TYPE VECTOR AS VARRAY(10) OF NUMBER(10, 0)
// CREATE TYPE MATRIX AS VARRAY(10) OF VECTOR
// create 2 descriptors : vector and matrix
ArrayDescriptor descVector =
ArrayDescriptor.createDescriptor("VECTOR", connection);
ArrayDescriptor descMatrix =
ArrayDescriptor.createDescriptor("MATRIX", connection);
// create matrix
double[] line1 = {15, 25, 35};
ARRAY arrayLine1 = new ARRAY(descVector, connection, line1);
double[] line2 = {17, 27, 37};
ARRAY arrayLine2 = new ARRAY(descVector, connection, line2);
Object matrix[] = {arrayLine1, arrayLine2};
ARRAY arrayMatrix = new ARRAY(descMatrix, connection, matrix);
// insert the matrix
PreparedStatement ps = connection.prepareStatement("INSERT INTO
MY_TABLE VALUES (?)");
((OraclePreparedStatement) ps).setARRAY(1, arrayMatrix);
ps.execute();
Unfortunately, this doesn't work.
Anyone has a better idea ?
Thanks for your help, bye.
Manuel Deslis Received on Wed Nov 10 2004 - 05:07:37 CST
![]() |
![]() |