Passing XML from Java to PL/SQL using CLOBs?
Hi. Here at the University at Buffalo, we're trying to develop an architecture where departments can send XML transactions to the business offices over HTTP. Since we don't have much Java expertise on staff, the boss has decided that we should use PL/SQL wherever possible. To that end, I have a Java servlet that calls PL/SQL stored procedures using JDBC.
My question is this: We anticipate that we will have the need to process documents larger than the limit on VARCHAR2 data. However, unless I am misunderstanding the documentation on working with LOBs, the LOB itself must already exist in the tablespace. How will I take the XML document I receive through the servlet and pass it through to the PL/SQL function which accepts it? This function, FYI, routes documents to various systems based on document type, checks user security, and does a bunch of other things before the XML document is committed to a table.
Is this possible? If there are already resources available that answer my question, can you point me in the right direction?
Thanks in advance,
Craig Drabik
Lead Programmer/Analyst
SUNY at Buffalo
null
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Craig Drabik ([email protected]):
Hi. Here at the University at Buffalo, we're trying to develop an architecture where departments can send XML transactions to the business offices over HTTP. Since we don't have much Java expertise on staff, the boss has decided that we should use PL/SQL wherever possible. To that end, I have a Java servlet that calls PL/SQL stored procedures using JDBC.
My question is this: We anticipate that we will have the need to process documents larger than the limit on VARCHAR2 data. However, unless I am misunderstanding the documentation on working with LOBs, the LOB itself must already exist in the tablespace. How will I take the XML document I receive through the servlet and pass it through to the PL/SQL function which accepts it? This function, FYI, routes documents to various systems based on document type, checks user security, and does a bunch of other things before the XML document is committed to a table.
Is this possible? If there are already resources available that answer my question, can you point me in the right direction?
Thanks in advance,
Craig Drabik
Lead Programmer/Analyst
SUNY at Buffalo<HR></BLOCKQUOTE>
You has to use temporary CLOB for this purpose.
If you needs some kind of examples I'll sent to you directly the codes.
Best regards, Marcelo.
null
Similar Messages
-
Is it possible to pass blob from java to PL/SQL ?
Hi, I try to bind a PL/SQL function who return a blob to a java class :
Signature of java method :
public static Blob getBLOB(int aId, String aJDBC) {Create PL/SQL function :
create or replace function aa_java(myPiId in number,myPiJDBC in varchar2) return blob
as language java
name 'zip.ReadBLOB.getBLOB(int,java.lang.String) return java.sql.Blob';
/In java code, my blob has the right size (150 Ko) but in PL/SQL, size = 0 !!!
Any ideas ?
Thank you, but I think I have a Java problem...
Here is my code :
package zip;
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
public class ReadBLOB {
public static BLOB getBLOB(int aId, String aJDBC) {
BLOB vBlob = null;
try {
DriverManager.registerDriver(new OracleDriver());
Connection connection = DriverManager.getConnection(
aJDBC,
PreparedStatement stat = connection
.prepareStatement("select image from aa_blob where id="+aId);
ResultSet rs = stat.executeQuery();
if (rs.next()) {
vBlob = (BLOB) rs.getBlob(1);
System.out.println("Taille 1 : "+vBlob.length());
connection.close();
} catch (Exception e) {
e.printStackTrace();
return vBlob;
public static void main(String[] args) throws Exception {
BLOB vBlob = getBLOB(1, "jdbc:oracle:thin:@vdn-ceg5:1521:DEV5");
System.out.println("Taille 2 : "+vBlob.getLength());
}When I run the main method, I have :
Taille 1 : 150260
Taille 2 : 86
!!!!????!!!!????
Thank you, but I think I have a Java problem...
Here is my code :
package zip;
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
public class ReadBLOB {
public static BLOB getBLOB(int aId, String aJDBC) {
BLOB vBlob = null;
try {
DriverManager.registerDriver(new OracleDriver());
Connection connection = DriverManager.getConnection(
aJDBC,
PreparedStatement stat = connection
.prepareStatement("select image from aa_blob where id="+aId);
ResultSet rs = stat.executeQuery();
if (rs.next()) {
vBlob = (BLOB) rs.getBlob(1);
System.out.println("Taille 1 : "+vBlob.length());
connection.close();
} catch (Exception e) {
e.printStackTrace();
return vBlob;
public static void main(String[] args) throws Exception {
BLOB vBlob = getBLOB(1, "jdbc:oracle:thin:@vdn-ceg5:1521:DEV5");
System.out.println("Taille 2 : "+vBlob.getLength());
}When I run the main method, I have :
Taille 1 : 150260
Taille 2 : 86
!!!!????!!!!????
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,
Prashant
Kiran 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
Passing XMLDocument from Java to PL/SQL
Hi - I'm running Oracle 9i Release 2 on Windows 2000 and 9Ias on Windows2000.
I have a class loaded into the DB with LoadJava which accesses a Servlet on the Appserver which returns a XML document. The class in the DB is wrapped by PL/SQL function.
The PL/SQL function is the initiator of the transaction - ie sequence as follows:
Client calls function - calls class in DB - calls Servlet - calls EJB - same route back. I do have a valid XMLDocument in the class after the call but can't get this back into the DB.
I have tried with XMLType but resulted in ora-600 errors and ultimately crashing the DB. Any suggestions as how to get the XMLDocument in?
Tks
code Snipets:
java code - this is the way I had checked the valid xml document.. seemed fine - I then changed all the XMLDocument's to XMLType and crashed the DB!!
import oracle.xdb.XMLType;
import oracle.sql.OPAQUE;
class TestServlet
public static XMLDocument getIsis ()
System.out.println("Message to standard output - pos 1");
XMLDocument incomingXMLDoc = null;
URL target = null;
try
incomingXMLDoc = new XMLDocument();
String appServer = "http://sdt10645:8888/t1/servlet/Servlet1";
target = new URL(appServer);
incomingXMLDoc = XMLHttp.doPost(target);
// ((XMLDocument)incomingXMLDoc).print(System.out);
This is the PL/SQL function
PACKAGE AJK1CALLS AS
FUNCTION TestServletCall RETURN xmltype IS
LANGUAGE JAVA
NAME 'TestServlet.getIsis() return oracle.xdb.XMLType';
END ajk1Calls;
This is the pl/sql function call
DECLARE
doc1 xmltype;
BEGIN
doc1 := ajk1calls.testservletcall;
END;
Any help appreciated !!
Tks
Andre
Please make sure to use the classes12.jar comes with Oralce9iR2.
Passing parameters from java jdbc to pl/sql
I’m calling stored procedures from java jdbc… but looking for nicer interfaces in terms of passing data. Has anyone come up with a good way to pass data from java jdbc to pl/sql without passing a million parameters? I’m thinking here of some type of structure like pl/sql rowtype or table index type or something else. Has anyone tried to create typed objects in oracle databases and access them from java?
Thanks, Patrick Caldwell
Hi Patrick,
Yes, I have created an Oracle object type, which I successfully returned to a java class, from a PL/SQL stored function, using JDBC. Environment was J2SE 1.3.1, with Oracle 8.1.7.4 on SUN [sparc] Solaris 7 with Oracle's JDBC (thin) driver. It was a while ago, so I don't remember the details very clearly, but I recall being able to figure it out quite easily using the Oracle documentation and the sample code available at Oracle's Technet Web site.
Hope this has helped you.
Good Luck,
Avi.
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
I am developing web services based GIS, I have XML file which was generated from Geoserver. I dont know how to link Java with XML and query XML from Java. I need help pls.
PAI
there are apis to parse xml using java,
http://www.cafeconleche.org/books/xmljava/chapters/ch09s06.html
try this link..
regards
Shanu
Hi
I want to use xml for updating files in an existing jar . so i want to call xml from java code and then come back to java code and do the remaining work in java code, pl guide me how to do this . what APIs are helpful for this regard
Thanks
You can't update files in a jar. Even if you could, you wouldn't use XML for that. You don't call XML. XML is not a programming language. So, basically your entire question is misguided.
Anyone knows how to pass value from Java to Perl program?
Did you write the perl program? Can you change it? Or are you trying to interface to something that already exists? This will limit your options, of course.
Anyway the first option is simple. The java program does this:
System.out.println("This is a line of input.");The perl program does this:
while(<>)and in that block, $_ is assigned to each line of input.
Then you can invoke both like this:
$ java MyJavaProgram | perl MyPerlProgram.pl
How to pass variable from Java to ABAP in BSPs
Hello experts,
taking into account the two environments (browser and server) I need to pass information from Java to ABAP.
After seen this link: Re: View Refresh
I have tried the next:
HTMLB: <input type="hidden" name="myFlag" value="">
ABAP: DATA: lv_height TYPE STRING.
JAVA: var intXo = readCookie("XEix");
JAVA: if ( intXo == 900 )
JAVA: else if (intXo == 725 )
ABAP: lv_height = request->get_form_field( 'myFlag' ).
ABAP: IF lv_height EQ 'X'.
ABAP: TRAYTAREAS_P = 'TRUE'.
ABAP: ELSE.
ABAP: TRAYTAREAS_P = 'FALSE'.
ABAP: ENDIF.
"document.all.myFlag.value" gets the correct value according the condition, but the ABAP code does not recover this value (lv_height is always initial).
Can you help me with that? I'm not able to see where is the mistake...
Exist any alternative way to recover in ABAP an JavaScrip value?
thanks in advance.
Arnau
Message was edited by:
Arnau Mustieles
Hi Raja
I think you are appointing to this posted solution:
HTMLB: <input type="hidden" name="myFlag" value="">
ABAP: DATA: lv_height TYPE STRING.
JAVA: var intXo = readCookie("XEix");
JAVA: if ( intXo == 900 )
JAVA: else if (intXo == 725 )
ABAP: lv_height = request->get_form_field( 'myFlag' ).
ABAP: IF lv_height EQ 'X'.
ABAP: TRAYTAREAS_P = 'TRUE'.
ABAP: ELSE.
ABAP: TRAYTAREAS_P = 'FALSE'.
ABAP: ENDIF.
but it doesn't work. Can you detect if there is any evident error there or the process is right?
Hi,
I would like to know how to include DOC TYPE reference node, when building XML from Java.
Thanks !!
SetDocType is available only in JDOM parser. I would like to know is it prossible without that.
Thanks !!
Passing a structure from Java to PL/SQL Procedure
Environment: Oracle DB, Tomcat/Apache
How do we pass a structure (Table Record Type) from Java to a PL/SQL Stored Procedure?
We are doing JSP-->JavaClass/Bean to communicate to DB. We have an existing PL/SQL packages/Procedure to insert records into table (These procedures have record types as in/out parameters). So is there a way to call these from Java?
Thanks in advance.
Ramesh
Oracle9 i JDBC Developers Guide and Reference(page 21-16):
It is not feasible for Oracle JDBC drivers to support calling arguments or return
values of the PL/SQL RECORD, BOOLEAN, or table with non-scalar element types.
However, Oracle JDBC drivers support PL/SQL index-by table of scalar element
types. For a complete description of this, see "Accessing PL/SQL Index-by Tables"
on page 16-21.
As a workaround to PL/SQL RECORD, BOOLEAN, or non-scalar table types, create
wrapper procedures that handle the data as types supported by JDBC. For example,
to wrap a stored procedure that uses PL/SQL booleans, create a stored procedure
that takes a character or number from JDBC and passes it to the original procedure
as BOOLEAN or, for an output parameter, accepts a BOOLEAN argument from the
original procedure and passes it as a CHAR or NUMBER to JDBC. Similarly, to wrap a
stored procedure that uses PL/SQL records, create a stored procedure that handles
a record in its individual components (such as CHAR and NUMBER) or in a structured
object type. To wrap a stored procedure that uses PL/SQL tables, break the data
into components or perhaps use Oracle collection types.
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
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 AM
Avi 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.
Is it possible to pass an xml from external system to EBS using BE
Hi All,
Is it possible to pass the xml payload as input parameter of a function subscribed to Business event? Or is it possible to pass table type as input to BE subscription function (SRF)? if yes how?
Thanks,
Workflow Business Events help creating Generate Function to generate an XML payload that in turn is made available to the Subscription's Rule Function. Also, at the time of Raising the Business Event, you could pass the XML payload (in the form of a CLOB) to the Raise API that will be passed along to the Business Event's Subscription Rule Function.
Hope this helps.
Vijay
Maybe you are looking for
-
Photoshop CC White Window Workaround Plugin Fails Version Test?
I'm sure everyone with a Wacom tablet on a Mac is aware of the "White window" issue. See the original discussion thread at: Drop Down Menus in Photoshop CS 6 Goes Blank In Mavericks Photoshop developers partook in the discussion on the thread, and a
-
Dashboard is not showing on the Dashboard banner (menu)
I have created total 15 Dashboards. In that when i am opeining Presentation services only 7 Dashboard's showing. Remaining Dashboard's not showing. I given access every one to Read to all the Dashboards and One Dashboard opening by default but it is
-
What are the master data maintained at the client level? What is the system to avoid the duplication of data records? How to see the client specific master data? Regards, Komal
-
Hi, I have developed the BSP page and calling it from the custome control in module pool data: html_control TYPE REF TO cl_gui_html_viewer. I have to store the result obtained from BSP page into Z table. The result appears in html control but i am un
-
Lost all masters, need way to merge previews to master as replacement
Hi all, Recently I accidently deleted the folder that contained most of my library (I didn't think they were refenced, I assumed they were all in my library file, but unfortunately this was not true) and this is causing me a major problem. My first s