Js Array from java List
I got to create an Array list this...
new Array('Requerimiento', '89', 'Esto es un requerimiento\nOtra l�nea', 'Producci�n', '90', 'Hola\nHola', 'Release', '91', '<BR>'));
exactly like this from a java List.. so i got to replace 'Requerimiento' for ((myObj)list.get(0)).getName(), replace '98' for ((myObj)list.get(0)).getId(). replace 'Esto es un requerimiento\nOtra l�nea' for ((myObj)list.get(0)).getDesc() and then the same cyclye but for position 1 in the list.
The array is dynamic so i can has as elements as the list has so i have no idea what to do and did this...
var taskTypes = new String();
List taskTypeList = timeKeeping.getValidTaskTypes(from, to);
for(int x = 0, i = 0; x < taskTypeList.size(); x += 3, i++) {
TaskType tt = (TaskType) taskTypeList.get(i);
%>
if(i + 1 == taskTypeList.size()) {
taskTypes.concat("<%= tt.getName() %>" + ',' + "<%= tt.getId() %>" + ',' + "<%= tt.getName() %>");
} else {
taskTypes.concat("<%= tt.getName() %>" + ',' + "<%= tt.getId() %>" + ',' + "<%= tt.getName() %>" + ',');
<%
%>but it doesn't work out...
help plz ! Thanks a lot.
String.concat() does not add the string to the string, it returns a new string combining the 2, so you'd have to do this:
taskTypes = taskTypes.concat("<%= tt.getName() %>" + ',' + "<%= tt.getId() %>" + ',' + "<%= tt.getName() %>");
But, you need to be writing JavaScript... (I assume it's an array of arrays...)
var aArray = new Array();
<%
List taskTypeList = timeKeeping.getValidTaskTypes(from, to);
for(int x = 0, i = 0; x < taskTypeList.size(); x += 3, i++) {
TaskType tt = (TaskType) taskTypeList.get(i);
%>
aArray[aArray.length] = new Array('<%= tt.getName() %>', '<%= tt.getId() %>', '<%= tt.getName() %>' ... );
<% } %>
Similar Messages
-
Passing an array from Java to Pl/SQL Procdures
I am relatively new to the Java world and I am unable to pass back an array from Java back to the calling PL/SQL procedure. I have read many of the posts that deal with this issue and in specificly have viewed Ask Tom. My main issue is trying to get the data types matched up. I am able to return varchar2, numbers, and the like, but an array of filenames is not happening. I have tried a variety of "types" but unable to accomplish the task. Please help.
I have my Java class basically defined as:
public static oracle.sql.ARRAY[] getCollection(String directory)
throws SQLException
{ // provide a directory and get a listing of files
File path = new File( directory );
String[] list = path.list();
return list;
SQL Type and PL/SQL Procedure is:
CREATE OR REPLACE TYPE PTO_FILE IS TABLE OF VARCHAR2(100);
create or replace function get_dir_collection( p_directory in varchar2 ) RETURN PTO_FILE
as language java
name 'DirCollection.getCollection( java.lang.String ) return oracle.sql.ARRAY[]';
/I know that it is not an ARRAY. It is however an "array" and I am attempting to map Java's String[][ to some "object" on the oracle side. I have looked at the link you sited and was not able to find the data mapping. I have found that mapping data types between different "languages" is some of the most difficult aspects of working with multiple languages.
Any suggestions? Thanks -
Example of passing String Array from java to C using JNI
hi all
i searched net for passing string array from java to C but i dont get anything relevent
i have
class stu
int rollno
string name
String [] sub
i want to pass all as String array from java to C and access it C side1. Code it as though it were being passed to another method written in java.
2. Redefine the method implementation to say "native".
3. Run jnih to generate a C ".h" file. You will see that the string array
is passed into C as a jobject, which can be cast to a JNI array.
4. Write the C code to implement the method and meet the interface
in the generated .h file. -
Passisng array from Java into PL/SQL procedure
Hi everybody!
I have type created with :
CREATE OR REPLACE TYPE my_type IS TABLE OF number;
Next I have procedure withinin a package which has parameters:
PROCEDURE my_proc
(p_Result OUT NUMBER,
p_Id table.column%TYPE,
p_MyType my_type
I call this procedure from Java :
import javax.sql.*;
import java.sql.*;
import oracle.jdbc.*;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
public class MyClass extends QueryClient {
private int Id;
private int type;
private Integer[] List;
private int result;
public MyClass(int Id, eType type,
Integer[] List) throws SQLException {
this.Id = Id;
this.type = (type.equals(eType.TYPE_EXPORT) ? 1 : 0);
this.List = List;
this.execute("{call my_package.my_proc(?,?,?,?)}");
public void body(CallableStatement stmt) throws SQLException {
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("MY_USER.MY_TYPE", getCon());
ARRAY array_to_pass = new ARRAY(descriptor, getCon(), this.List);
// register the type.
stmt.registerOutParameter(1, OracleTypes.NUMBER); // result of procedure calling
stmt.setInt(2, this.Id );
stmt.setInt(3, this.type);
stmt.setArray(4, array_to_pass);
// execute and retrieve the result set
stmt.execute();
this.result = stmt.getInt(1);
public int getResult() {
return result;
EVERYTHING WORKS FINE, BUT when I move type "my_type" into package header
TYPE my_type IS TABLE OF number;
I receive error after calling procedure
java.sql.SQLException: invalid name pattern: MY_USER.MY_TYPE
I dropped type my_type after moving it into package. So there is only one my_type, in the package.
User who call procedure is owner of the package.
So questions are:
1. Is it possible to have my_type within package without error?
2. Is it possible to describe my_type without having a connection to database? My aim is eliminate number of connections to database.
Thanks all.
Matus.You can't use the packaged type for this. You need to use the original collection type (i.e. via the CREATE TYPE syntax) as you have discovered yourself.
Regards -
Passing String Array from Java to PL/SQL
Hi,
We are having couple of packages which have been written in PL/SQL . I would like to know how i can send arrays as input parameters from Java to any stored proc in Oracle. I am having Oracle 8i as the DB and am using Websphere RSA for deployment purposes.
please find below Java , PL/SQL code and exception
PL/SQL Code :
PACKAGE PKG_SURCHARGE
IS
TYPE commodity_key IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
PROCEDURE RETRIEVE_CHARGES
in_Commodity_tab IN commodity_key,
IS
BEGIN
dbms_output.put_line('in_Commodity_tab(' || '0' || ') : ' || in_Commodity_tab(0) );
Java Code :
CallableStatement cstmt=null;
Connection conn=null;
try{
conn=getConnection();
System.out.println("++++++connected");
String sqlStr = "{call Pkg_Surcharge.RETRIEVE_CHARGES(?) }";
cstmt = conn.prepareCall(sqlStr );
//1.
String[] javaArray={"20081117","20081117"};
ArrayDescriptor dateDescripter = ArrayDescriptor.createDescriptor( "commodity_key", conn );
oracle.sql.ARRAY dateArray = new oracle.sql.ARRAY(dateDescripter, conn, javaArray);
System.out.println("++++++registered-1");
Catch (Exception e){
e.printStackTrace();
Exception Occured:
java.sql.SQLException: Invalid Pattern Name <Schema Name>.commodity_key
Appreciate your help in this regard
Thanks
Srini
Edited by: [email protected] on Nov 25, 2008 4:55 AMAvi is correct. You must create a varray or nested table instead of using a PL/SQL index-by table.
SQL> create type commodity_key as varray(#) of varchar2(500);
or
SQL> create type commodity_key as table of varchar2(500);
Use the varray if you know the number of items in the array. Otherwise, use the nested table. -
Passing array from java stored procedure to plsql
I have a java store procedure that is parsing an xml document and returning element values to my plsql application(8.1.7). I'm mapping a java.lang.String return type to VARCHAR2. However I'm running into the 4k limit when trying to return a string from java that is over 4k. Truncation of varchar returning over 4k is a known issue in 8i.
So my next idea was to split that value of the element into 2000char and put in an array then pass that back to the plsql procedure. I know that oracle.sql.ARRAY can be converted into a plsql TABLE. But I believe you can only use the oracle.sql.ARRAY type when you are doing jdbc programming and are working with a connection.
SO FINALLY MY QUESTION IS...
Can anyone think of a solution that will allow me to pass over 4k of character data from my java stored procedure (not jdbc), back to my plsql app?
Thanks.My understanding is that oracle 8 has a 4k limitation on any plsql function return data. A varchar can hold 32k within a function/package, but it cannot return more than 4k outside it's scope.
Do you have an example you could share where you use the clob as a return type?
Thanks! -
Pass arrays from Java to PL/SQL procedure.
Hi All,
Can some body give an example, where an array of strings is passed from java to a PL/SQL procedure.
Any help in this regard is appreciated.
Thanks,
PrashantKiran Kumar Gunda wrote:
I would want to use Oracle provided (Oracle Extensions) API to pass arrays to PL/SQL
procedure from Java. I am using weblogic connection pool, but the 'createDescriptor'
method donot allow Pooled connection. So I have taken Physical Connection by casting
to 'WLConnection'. Now, weblogic strongly suggest NOT to use this,as pooling capabilities
will be disabled.
But by setting RemoveInfectedConnectionsEnabled to false, we can ask weblogic
to return the Physical Connection to Pool. I have tested this with the attached
code. I DON'T find any issue.Good. The only real risk to obtaining the physical connection is retaining and
using it beyond the current thread execution. Your code looks OK. The only thing
I'd suggest is to add to the finally block. I would put a separate try-catch-ignore
block around every action in the finally, so if one fails, the others are still
done.
As long as you're writing good JDBC like that, there is no risk to telling the
pool to trust the code, by setting RemoveInfectedConnectionsEnabled to false.
That way you'll retain all the performance of the pools.
Joe
>
I want your opinion in this, so that I will be confident in using this feature
in our application.
Note : Please look at the sample code that I am using. I AM NOT GOING TO USE PHYSICAL
CONNECTIONS for normal operations. I will use Physical Connection only when I
want to pass Arrays to Oracle.
Thanks
Kiran -
ORA-00932 when trying to pass ARRAY from Java SP to PL/SQL
Hi all
I am trying to pass ARRAYs back and forth between PL/SQL and Java stored procedures. But I keep getting:
ORA-00932: inconsistent datatypes: expected a return value that is an instance of a user defined Java class convertible to an Oracle type got an object that could not be converted
Here's my PL/SQL:
create or replace type CONTENTP.sentences_array as VARRAY(1000) of CLOB
-- I've also tried .. as TABLE of CLOB and varray/table of VARCHAR2
declare
proc_clob CLOB;
arr SENTENCES_ARRAY;
begin
SELECT document_body
into proc_clob
from documents
where document_id = 618784;
arr := processdocument.sentencesplit (proc_clob);
end;
PROCESSDOCUMENT package definition:
CREATE OR REPLACE PACKAGE CONTENTP.PROCESSDOCUMENT AS
FUNCTION sentenceSplit(Param1 CLOB)
return SENTENCES_ARRAY
AS
LANGUAGE java
NAME 'com.contentp.documents.ProcessDocument.sentenceSplit(oracle.sql.CLOB) return oracle.sql.ARRAY';
FUNCTION removeHTML(Param1 CLOB)
return CLOB
AS
LANGUAGE java
NAME 'com.contentp.documents.ProcessDocument.removeHTML(oracle.sql.CLOB) return oracle.sql.CLOB';
end;
Java sentenceSplit code:
public static oracle.sql.ARRAY sentenceSplit ( CLOB text) throws IOException, SQLException
Connection conn = new OracleDriver().defaultConnection();
String[] arrSentences = sent.getsentences ( CLOBtoString (text) );
ArrayDescriptor arrayDesc =
ArrayDescriptor.createDescriptor ("SENTENCES_ARRAY", conn);
ARRAY ARRSentences = new ARRAY (arrayDesc, conn, arrSentences);
return ARRSentences;
I have confirmed that the String[] arrSentences contains a valid string array. So the problem seems to be the creation and passing of ARRSentences.
I have looked at pages and pages of documents and example code, and can't see anything wrong with my declaration of ARRSentences. I'm at a loss to explain what's wrong.
Thanks in advance - any help is much appreciated!I am trying to do something similar but seems like getting stuck at registerOutParameter for this.
Type definition:
CREATE OR REPLACE
type APL_CCAM9.VARCHARARRAY as table of VARCHAR2(100)
Java Stored Function code:
public static ARRAY fetchData (ARRAY originAreaCds, ARRAY serviceCds, ARRAY vvpcs) {
Connection connection = null;
ARRAY array = null;
try {
connection = new OracleDriver ().defaultConnection();
connection.setAutoCommit(false);
ArrayDescriptor adString = ArrayDescriptor.createDescriptor("VARCHARARRAY", connection);
String[] result = new String [2];
result[0] = "Foo";
result[1] = "Foo1";
array = new ARRAY (adString, connection, result);
connection.commit ();
return array;
} catch (SQLException sqlexp) {
try {
connection.rollback();
} catch (SQLException exp) {
return array;
Oracle Stored Function:
function FETCH_TRADE_DYN_DATA (AREA_CDS IN VARCHARARRAY, SERVICE_CDS IN VARCHARARRAY,VV_CDS IN VARCHARARRAY) return VARCHARARRAY AS LANGUAGE JAVA NAME 'com.apl.ccam.oracle.js.dalc.TDynAllocation.fetchData (oracle.sql.ARRAY, oracle.sql.ARRAY, oracle.sql.ARRAY) return oracle.sql.ARRAY';
Java Code calling Oracle Stored Procedure:
ocs = (OracleCallableStatement) oraconn.prepareCall(queryBuf.toString());
ArrayDescriptor adString = ArrayDescriptor.createDescriptor("VARCHARARRAY", oraconn);
String[] originAreaCds = sTDynAllocationVO.getGeogAreaCds();
ARRAY areaCdArray = new ARRAY (adString, oraconn, originAreaCds);
ocs.registerOutParameter(1, OracleTypes.ARRAY);
ocs.setArray (2, areaCdArray);
String[] serviceCds = sTDynAllocationVO.getServiceCds();
ARRAY serviceCdsArray = new ARRAY (adString, oraconn, serviceCds );
ocs.setArray (3, serviceCdsArray);
String[] vvpcs = sTDynAllocationVO.getVesselVoyagePortCdCallNbrs();
ARRAY vvpcsArray = new ARRAY (adString, oraconn, vvpcs);
ocs.setArray (4, vvpcsArray);
ocs.execute();
ARRAY results = ocs.getARRAY(1);
Error I get:
Parameter Type Conflict: sqlType=2003
Thanks for help in advance. -
How to Pass String array from Java to PL/SQL and this use in CURSOR
hi,
I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
This array containing like (SYMPTOM ) to be returned from the java to the
pl/sql (I am not querying the database to retrieve the information).
I cannot find an example on this. I will give the PL/SQL block
create or replace procedure DISEASE_DTL<*** String Array ***> as
v_SYMPTOM number(5);
CURSOR C1 is
select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
order by a.DISEASE_NAME ;
begin
for C1rec IN C1 loop
select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
values (SL_ID_SEQ.nextval,
C1rec.DISEASE_NAME,
(4/v_SYMPTOM), --------**** 4 is no of array element (n)************
(1-(4/v_SYMPTOM)));
end loop;
commit;
end DISEASE_DTL;
Please give the proper solution and step ..
Thanking you,
AsishI've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/ -
Help creating an array from a list of vector item
I am writing a Email Handling class that uses an Email class that I have already written. The spec requires me to (A.) Create a DisplayEmail(Email[] e) method that takes and array of email messages and displays them in the terminal window. And then (B) to create some retrieval methods ie: Email [] RetrieveSubject(String searchValue) which "will allow me to retrieve objects from the data structure created in (A.)and sorts them.
I wonder if you could give my some advice on how to implement this? I have used a Vector to store the emails. Here is what I have so far. . From what I understand I am suppose to create array methods for all of these tasks. Don't know where to begin, can u help please. I've created a vector to store the emails, but I am not sure about the array method bit. As you can see all of my methods are standard and I think they need to be arrays. Please Help
import java.util.*;
public class EmailHandler{
private Vector emails;
public EmailHandler(){
emails = new Vector();
public EmailHandler(int size){
emails= new Vector(size);
public void addEmail(Email e){
emails.addElement(e);
public void displayEmail(Email de)
public void displayArrayOfEmails(Email[] ea)
public Email RetrieveSender(String searchSender)
Email thisEmail;
//look through vector for search element
if(emails.size()>0){
for (int i=0;i<emails.size();i++){
//take emails in turn search for subject
thisEmail = (Email) emails.elementAt(i);
//check subject against search value input
if(thisEmail.getSender().equalsIgnoreCase(searchSender)) {
return thisEmail;
} //if you find yourself here, no subject is found
return null;
public Email RetrieveRecipient(String searchRecipient)
Email thisEmail;
//look through vector for search element
if(emails.size()>0){
for (int i=0;i<emails.size();i++){
//take emails in turn search for subject
thisEmail = (Email) emails.elementAt(i);
//check subject against search value input
if(thisEmail.getRecipientName().equalsIgnoreCase(searchRecipient)) {
return thisEmail;
} //if you find yourself here, no subject is found
return null;
public Email RetrieveSubject(String searchSubject)
Email thisEmail;
//look through vector for search element
if(emails.size()>0){
for (int i=0;i<emails.size();i++){
//take emails in turn search for subject
thisEmail = (Email) emails.elementAt(i);
//check subject against search value input
if(thisEmail.getSubject().equalsIgnoreCase(searchSubject)) {
return thisEmail;
} //if you find yourself here, no subject is found
return null;i've anwered your question in your crosspost over here:
http://forum.java.sun.com/thread.jsp?forum=31&thread=472997&tstart=0&trange=30 -
Pass 2D array from java to PLSQL
HI,
My requirement is that I have to pass dynamic parameters to be stored in a table. The table I have is
CODE || TAG_LABEL || TAG_COLMN_NAME
023 || Registration || CHAR_TAG1
023 || Agreement Number || NUM_TAG1
023 || Agency || NUM_TAG2
023 || Start Date || DATE_TAG1
this table A. gives me the list of all possible parametes
CODE || CHAR_TAG1 || CHAR_TAG2 || NUM_TAG1 || NUM_TAG2 .. ..
023 || 420/09 || -- || 100023 || 1002
021 || -- || 400030 || -- || --
023 || 450/10 || -- || 100025 || --
this table B gives the place where the values for this parameter has to be stored.So for code 023 if I have parameters say Registration='240/10' and start_date = '10/02/2010' then, how do I pass these dynamic paramters to the plsql and from there how do i handle storing this in my final Table B.
I searched the net for Dynamic sql and I am very basic in PLSQLs. Can anyone please help or atleast if there is a documentation that does exactly this, it would be very helpful.
Thanks
RacheFrom the pl/sql side you need to create your object types
create or replace type sample_array_obj
as object( firstitem varchar2(20 char),
seconditem varchar2(10 char)
create or replace
type sample_array_type is table of sample_array_objand then you need to grant execute access on both the object and type
grant execute on sample_array_obj to public;
grant execute on sample_array_type to public;you have to declare these to java then. (I'm not a java programmer, but the java then has to get its collection type from the database) -
ResultSet from Java Stored Procedures
Hi,
How do I obtain a resultset from a Java Stored Procedure?
My stored procedure, deployed in Oracle8i, has Database package as sample.Have published setConnection() and getDept() methods.
Code for Java Stored Procedure:
package SPPackage;
import java.sql.*;
public class StoredProcApplication {
protected static Connection connection = null;
protected static Statement stmt = null;
protected static ResultSet res = null;
public static void setConnection() throws SQLException {
connection = new oracle.jdbc.driver.OracleDriver().defaultConnection();
public static void getDept(Object[] obj) throws SQLException {
if (connection == null) {
setConnection();
if (stmt == null) {
stmt = connection.createStatement();
if (res == null) {
res = stmt.executeQuery("select * from DEPT");
obj[0] = res;
Code for TesterApplication :
package SPPackage;
import java.sql.*;
public class TesterApplication {
private static final String URL = "jdbc:oracle:thin:@sandeep:1521:oracle8i";
private static final String userId = "sandeep";
private static final String password = "sandeep";
private Connection connection;
private CallableStatement stmt;
private ResultSet res;
public void setConnection() throws ClassNotFoundException,SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(URL,userId,password);
public void getResultFromSP() throws SQLException {
//prepare to call the stored procedure
stmt = connection.prepareCall("{call sample.getDept(?)}");
//register the OUT parameters
stmt.registerOutParameter(1,Types.OTHER);
//execute the query
stmt.execute();
ResultSet res = (ResultSet)stmt.getObject(1);
while (res.next()) {
System.out.print(res.getInt(1) + " | " );
System.out.print(res.getString(2) + " | " );
System.out.print(res.getString(3) + " \n " );
public TesterApplication() throws SQLException,ClassNotFoundException {
try {
setConnection();
getResultFromSP();
} finally {
if (res != null) { res.close(); res = null; }
if (stmt != null) { stmt.close(); stmt = null; }
if (connection != null) { connection.close(); connection = null; }
public static void main(String[] args) {
try {
TesterApplication ta = new TesterApplication();
} catch (Exception e) {
System.err.println("Error while executing stored procedure " + e.getMessage());
e.printStackTrace();
When I run the TesterApplication, I get the following exception :
java.sql.SQLException: Invalid column type: get_internal_type
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.get_internal_type(Compiled Code)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Compiled Code)
Also, if I want to execute the ResultSet in the stored proc itself, and return the values as Arrays of int[], and String[], how do I do it?By default the you can populate only int[0], String[0] , i.e. only one value!!!
if my statement is unknown, i.e, it might return a combination of updates and resultsets, how do I go about processing the result?
Please advise!!
TIA
Sandeep
nullHi kkirk,
I found the post you mentioned.Well it dates back to November 1999 - "Problem returning resultset or ARRAY from java stored proc" by Stuart Popejoy ([email protected]).Too bad, it is still not solved!!
I am not very good at PL/SQL.However, it would still be helpful, if you could post the code here, or at my email address.
Meanwhile, I was trying this during the week-end.There seems to be a glimmer of hope!!
Let me know, if this makes sense :
CallableStatement cs = connection.prepareCall("begin open ? for select * from dept; end");
try {
cs.registerOutParameter(1,OracleTypes.CURSOR);
ResultSet res = ((OracleCallableStatement)cs).getCursor(1);
while (res.next()) {
//get the values
} catch (Exception e) {
e.printStacktrace();
However, I am getting an exception trace
Error while executing stored procedure Invalid column type: getLong
java.sql.SQLException: Invalid column type: getLong
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getLongValue(Compiled Code)
Not quite sure why this is happening!!
TIA,
Sandeep
null -
How to send a Varying Array param to a PL/SQL Stored Procedure from Java
* I am VERY new to jdbc, and even somewhat new to Java
* I'm using Java 1.5, Oracle 10g.
* I need to call the following PL/SQL Stored Procedure from Java:
procedure setEventStatus
i_deQueueStatus in deQueueStatus_type
*deQueueStatus_type is the following (an array of deQueueStatus_OBJ):
CREATE OR REPLACE TYPE deQueueStatus_OBJ as object
eventID number (20),
dequeuestatus varchar2(20)
CREATE OR REPLACE TYPE deQueueStatus_TYPE IS VARYING ARRAY(500) of deQueueStatus_obj
*I have created a Java object as follows:
public class EventQueueDeQueueStatus
long eventID;
String dequeueStatus;
EventQueueDeQueueStatus(long eventID, String dequeueStatus)
this.eventID = eventID;
this.dequeueStatus = dequeueStatus;
I have an ArrayList of these.
I need to pass this list to the Stored Procedure. How do I create a java.sql.Array so I can call CallableStatement.setArray to set the parameter? Or do I use something else? I have tried setObject with both the ArrayList and also with a primitive array, but got "Invalid Column Type" both times.
Any help would be greatly appreciated. I just got this task today, and I have to make it work by Tuesday :-( !
Thanks,
KathyKathy,
Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
Good Luck,
Avi. -
Need help on returning arrays from C++ to Java
Hi all, I hava a C++ application that contains a method that will return a float array to Java. I was able to write the Java Code, the JNI code to call the C++ method and compile them successfully. However on calling the native method from Java, the data in the array returned was not what I want. Please look through my code and see what is wrong with it.
My Java Code:
public native float[] Statistics(int inputKey); // This is the native method
public float[] Stats(int k){ //Java method to call the native method so that I can use it in a Bean for a JSP.
inputKey = k;
float[] p = new float[4];
p = Statistics(inputKey);
return p;
For this native method, an integer is passed from Java to the native side and the native method will use this integer to generate a float array size of 4 and populate it with data and return it back to Java.
My JNI code
extern "C"
JNIEXPORT jfloatArray JNICALL
Java_com_jspsmart_upload_FinalWaterMark_Statistics(JNIEnv *env, jobject obj, jint inputKey)
jfloatArray floatArray = env->NewFloatArray(4); //This creates a new Java floatArray to store the C++ array
CWatermarker2App p; // This is the C++ class to be used
jfloat *stats = p.OnWatermarkStatistics(inputKey) // The C++ method returns a float pointer for an array of size 4
env->SetFloatArrayRegion(floatArray, 0 , 4 , stats); //storing the C++ float array into the Java float Array
return floatArray; // return the Array to Java
In this example, I should have the data returned as [4952.0 2529.0 1706.0 33.6] in the array.
But i am getting junk instead like 2.53E-23, 1.402E-15 etc..
Is this a type conversion mistake?
Please help!The first thing I notice - probably not the problem - is the line defining p. There is no reason to define this as an array of size 4, because the return from the native method is going to wipe that definition, replacing it with the return value of the native method. Alternatives:
1. float[] p = null.
2. float[] p = Statistics(inputKey);
3. return Statistics(k); -
Need help on passing an array to java routine from PL/SQL
I got a math routine in java and the idea is have an array of integer and the java routine does some computatoin and then pass the array back to pl/sql
and I google the web most code is calling pl/sql from java but not the other way round. any help will be really appreciated.
{code}
package tst;
import java.util.*;
public class plsql3 {
private final static int factor1 = 2;
public static void getFib2(int[] in, int[] out, int k){
for (int i=0;i<=k-1;i++){
out[i]= in[i] * factor1;
public static void main(String[] arg){
int[] in2 = {1,2,3,4,5};
int[] out2= {0,0,0,0,0};
getFib2(in2,out2,2);
for ( int j = 0 ; j <= out2.length-1;j++) {
System.out.println(out2[j]);
{code}
{code}
CREATE or replace PROCEDURE getfib5 (x IN OUT numlist, y IN OUT numlist, k in number)
AS LANGUAGE JAVA
NAME 'tst.plsql3.getFib2(int[], int[],int)';
set serveroutput on format wraped;
declare
in2 numlist := numlist(1,2,3,4,5,6);
out2 numlist := numlist(0,0,0,0,0,0);
begin
--in2(0) := 1;
--in2(1) := 2;
--in2(2) := 3 ;
for i in 1..in2.count
loop
dbms_output.put_line(in2(i));
end loop;
for i in 1..in2.count
loop
dbms_output.put_line(out2(i));
end loop;
getFib5(in2,out2,2);
for i in 1..in2.count
loop
dbms_output.put_line(in2(i));
end loop;
for i in 1..in2.count
loop
dbms_output.put_line(out2(i));
end loop;
--dbms_output.put_line(in2.count);
end;
{code}
{code}
javac -source 1.5 -target 1.5 tst/plsql3.java
{code}
Error report:
ORA-00932: inconsistent datatypes: expected a value at argument position 1 that is convertible to a Java int got an Oracle named TYPE (ADT, REF etc)
ORA-06512: at "TK1.GETFIB5", line 1
ORA-06512: at line 18
00932. 00000 - "inconsistent datatypes: expected %s got %s"
*Cause:
*Action:http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:3696816290928
Maybe you are looking for
-
Extracting AVI frames - converting to readily accessible BMPs
Hi, Im at a roadblock currently, I need to extract frames from an AVI video then convert it to BMP images and load/apply it as a texture to an object in a 3D scene. Now the problem is not extracting the frames, Ive managed to extract the frames using
-
POP and IMAP side by side in Mail
Hi, is it ok to run POP and IMAP accounts side by side in Mail? I'm using POP but I want to switch to IMAP and set up a first IMAP account...
-
How to run different Oracle client versions on the same PC
I have developped an application (.Net 2.0, ODP v. 10). I must run it on PC where Oracle client version 8 is installed. The PC cannot be upgraded because of a client software running under this version. I tried to install ODP v. 10 on this PC in diff
-
I'm getting a strange error in FF on MS 2000 server but it doesn't appear in FF on Windows XP: dsContext has no properties [Break on this error] resultStr += dsContext.getNumRows(); Spry.Data.js line 4253 Anyone have any ideas?
-
Splitting a string with a delimiter
Hi, Below are the lines of code in ABAP. v_gpdwstring(17) TYPE c, v_afterdec(3) TYPE c, v_beforedec(10) TYPE c, SPLIT v_gpdwstring AT '.' INTO v_beforedec v_afterdec. The test value for v_gpdwstring = "1.53-" w