Home » Developer & Programmer » JDeveloper, Java & XML » Binding array type from java code
Binding array type from java code [message #92723] Tue, 21 December 2004 04:22 Go to next message
Rudi Vankeirsbilck
Messages: 1
Registered: December 2004
Junior Member
I have this stored procedures that takes an array of strings as an argument:

CREATE OR REPLACE TYPE StringArray AS VARRAY(100) OF VARCHAR2(16);

CREATE OR REPLACE PACKAGE mypackage AS
...
PROCEDURE doSomething(v_strings IN StringArray); -- This is line 57 by the way
END;

My java code looks something like:
String[[]] strings = ...;
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("STRINGARRAY", connection); // case is important and type should be a global type
CallableStatement cs = connection.prepareCall("CALL mypackage.doSomething(?)");
cs.setArray(1, new java.sql.Types.ARRAY(descriptor, connection, strings));

This all works fine until I actually execute the statement. Then I get the following error:
Caused by: java.sql.SQLException: ORA-06531: Reference to uninitialized collection
ORA-06512: at "BLUETEST.MYPACKAGE", line 57

Line 57 is the where the procedure is declared in the package body, the first actual line of code is more down.

Now I have found quite some problem descriptions with that ORA error but all are dealing with OUT parameters that were not correctly initialized, i.e. the array constructor had not been called. In my case however, the array is initialized by the java code and then bound to the sql statement. You would expect that the jdbc driver takes care of correctly initializing the PL/SQL collection wouldn't you.

Does anybody know if I need to do anything extra?

Many thanks,

Rudi.
Re: Binding array type from java code [message #109394 is a reply to message #92723] Thu, 24 February 2005 02:00 Go to previous message
fastlearner
Messages: 1
Registered: February 2005
Junior Member
heres my program, i want to put array on here. That could display this SAMPLE output:

Enter No. of Records: 2

Enter Student Id:012
Enter Student Fname:Lisa
Enter Student Lname:Wilson
Enter Student Course:BSCT
Enter Student YrSec:1-F

Enter Student Id:013
Enter Student Fname:Luna
Enter Student Lname:Lisano
Enter Student Course:BSCS
Enter Student YrSec:3-F

Enter Student Id:012
Enter Student Fname:Lisa
Enter Student Lname:Wilson
Enter Student Course:BSCT
Enter Student YrSec:1-F
Enter Student Id:013
Enter Student Fname:Luna
Enter Student Lname:Lisano
Enter Student Course:BSCS
Enter Student YrSec:3-F

how could do that? i could only display the 2 records and i cant display the whole output with those information. please help ...thank you

import java.io.*;
public class prefinal
{
public static void main(String[[]] argv) throws IOException
{
BufferedReader b= new BufferedReader(
new InputStreamReader(System.in));

int cer,i,a,rec;
String t,y,u,r,w,q;

System.out.println("Enter the Number of record(S):");
cer=Integer.parseInt(b.readLine());

for (i=0; i<cer;i++)
{
System.out.println("\nEnter ID :");
t =b.readLine();
System.out.println("\nEnter fname :");
y =b.readLine();
System.out.println("\nEnter lname :");
u =b.readLine();
System.out.println("\nEnter course :");
r =b.readLine();
System.out.println("\nEnter yrsec :");
w =b.readLine();
System.out.println("\nEnter address :");
q =b.readLine();

}
}
}
Previous Topic: How to Connect JAVA app to Oracle 8.0.5
Next Topic: Network Adapter could not establish connection
Goto Forum:
  


Current Time: Mon Nov 25 17:14:45 CST 2024