OK. You asked for it. I don't claim this is the easiest way, but it works.
First, I will assume your vectors are collections of primitives. The
strategy is to mirror your target object on both sides, eg. Oracle and Java.
We'll create an array of double on the Java (servlet) side, and a type
varray on the Oracle side. In this example, an array of double is created in
Java and passed to Oracle. Sorry if wanted to go in the other direction.
You'll need these Oracle classes.
oracle.sql.ARRAY;
oracle.sql.ArrayDescriptor;
oracle.sql.SQLName;
Build an array of double on the Java side.
double javaArray[] = {0.0,0.0,0.0,0.0,0.0};
Then an ArrayDescriptor
ArrayDescriptor arrayDescriptor = new ArrayDescriptor(new
SQLName("COORD_SET", conn), conn);
conn is the JDBC connection object. The COORD_SET is the Oracle type, which
I will define below.
Finally, connect the javaArray to the oracle.sql.ARRAY, create the object.
ARRAY convertedArray = new ARRAY(arrayDescriptor, conn, javaArray);
If you write some kind of function that passes an ARRAY object to Oracle, it
can be processed as a type in Oracle.
In Oracle, you need to create the type:
create type coord_set as varray(5) of number;
/
Don't forget the necessary grants and synonyms.
I hope this helps,
Dave
-----Original Message-----
From: Deo Prakash [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 09, 2001 11:59 PM
To: [EMAIL PROTECTED]
Subject: JDBC problems
Hi Friends,
I am facing one problem....
Inside a Java class I need to call a oracle procedure for a set of inputs.
In another words I need to pass a Vector to a oracle procedure. I am using
JDBC for that. But How to pass a VECTOR into a Oracle Procedure using JDBC
API.
Presently I am calling the CallableStatement for each element of the Vector
which takes time. In place of that I want to do it in one shot....
Pls Help me in this..........
Regards,
Deo
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html