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 ?

A: Is it possible to pass blob from java to PL/SQL ?

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
!!!!????!!!!????

Similar Messages

  • 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

  • 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.

  • Pass value from Java to Perl

    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?

  • Is it possible to pass variables from Tidal to the Peoplesoft run controls?

    Does anyoen know
    •1) Is it possible to pass variables from Tidal to the Peoplesoft run control page such as current date?
    An example would be updating run control parameters for a PSQUERY.
    •a) From date
    •b) To date
    •c) Business units
    Thanks,
    Jay

    Edit the job - go to Run Controls Parameters tab - select the param you want in the Override column then click on the Variables button on the bottom and select the variable you want

  • Is it possible to pass contacts from pc to iphone 5?

    is it possible to pass contacts from pc to iphone 5?

    Hello yoseba, 
    Thank you for contributing to the Apple Support Communities. 
    It sounds like you want to move or sync contacts on your PC with your iPhone 5.
    Depending on which application on your PC stores your contacts, you may be able to sync them with your iPhone using iTunes or iCloud. 
    For example, iCloud will sync contacts from Outlook 2007 or later, as mentioned in the System requirements for iCloud.
    You can find the steps to set up iCloud or iTunes to sync on these support pages:
    Apple - iCloud - Learn how to set up iCloud on all your devices.
    Sync your iPhone, iPad, and iPod with iTunes using USB - Apple Support
    Sincerely,
    Jeremy 

  • 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 parameters from Java to an Oracle proc

    I am passing 3 parameters from Java method to an Oracle function.
    The Java method is called getStatic(String szparams) which invokes oracle function
    getStatic("GB1000");
    Oracle procedure
    SELECT XMLELEMENT("Underlying",
           XMLELEMENT("Code",a.code))
    FROM underlying a
    WHERE xml.extractval(a.xml,'/tables:underlying/tables:isin/text()',xml.getns('NS_TABLES'))=':arg1:' Passing 1 parameter works fine.
    2)Now I need to pass 3 parameters to the same function
    getStatic("GB1000\i\common");
    Oracle procedure
    SELECT
    XMLELEMENT(":arg2::Underlying", XMLATTRIBUTES(a.code "value", ':arg3:' as "xmlns::arg2:", 'http://www.AAA.com/common' as "xmlns:common"),
    XMLELEMENT("common:Code", a.code),
    FROM
      table a
    WHERE
      a.code = ':arg1:'Passing 3 params doesnt work.
    I tried using this way also:
    getStatic("GB1000\\i\\common"); -- still doesnt work.
    Is there a specific format where you can pass 3 parameters to the same method in Java?
    No offence meant,as this may sound silly.
    Thanks,

    Hi Nitin,
    yes, it is possible to pass parameters as URL parameters to the WDA applivcation. In WDA, for the handler method of your windows default Inplug (in standard the method is named HANDLEDEFAULT) define the parameters that you like to receive thru URL. When defining the WDA application, you can also set default parameters to avoid a dump, when parameters are not provided via URL.
    I just tried it out, it works.
    Kind regards
    Andreas

  • How to pass session from Java to Perl

    Hi,
    I need to pass a session value from Java to Perl, does anyone knows how can I do it?
    Thanks

    If you want to run java code from Perl, and have it return a single value, that's one thing: but having Perl interact with java code - calling methods, returning values - that may not be possible.
    Look into python to see if it may be what you're looking for. It's a scripting language that allows real interaction with java.
    If all you want to do is run java code and have it return some data, that would be trivial, so I assume that's not what you mean. But in case it is heres an idea:
    Set up a network connection between them with your own protocol, seeing as both languages are good at networking.

  • 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 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 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!

Maybe you are looking for

  • How to get Status of Archived Delivery Document line item

    Hi Folks, I want read the Status of line item of archived delivery document. As delivery is archived, it is not found in LIKP/LIPS. So I got the archived delivery document from VBFA table.But this does not contain the status field. Is there any progr

  • IPod appearing in Device Manager as unknown device

    Hi, I'm currently using an iPod Nano 4th Gen. and it is appearing in Device Manager as an unknown device. I found this out after the error message "USB device not recognised" or something, and followed instructions. I'm currently clueless on what to

  • When is 10.1..2.3 CP6 scheduled to release?

    I have an issue where all users can login to Discoverer without problem except when logging in as "SYSADMIN". Doc id 949582.1 lists workaround, but I'd like to find out when Disco 10.1.2.3 CP6 is going to be out. Thanks, Ian

  • Images reduce in size on export

    When exporting images from Aperture to desktop or external hard drive, they reduce in size by more than half. I have preview preferences set to 'do not limit' but they still export smaller... Please advise how to remedy this dilemma.

  • Where is 64-bit version of reset ulitity?

    Bought a used - but in working condition iPod Shuffle 2nd Gen.  Tried to charge/sync it and got a dialog box - not recognized by iTunes. Not showing up under Devices in iTunes. Directed me to iPod reset ut ility setup, which will not dowload - its fo