473,725 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem while calling java stored procedure which connects to db2.

2 New Member
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2.
Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and recompiling/executing the code with 1.4.1 (deploying the newly compiled stored procedure code as well).

This is the original exception that I got before I tried any code modifications:

java.io.IOExcep tion: invalid offset/length
at COM.ibm.db2.app .BlobOutputStre am.write(Lob.ja va:337)
at java.io.ObjectO utputStream$Blo ckDataOutputStr eam.write(Objec tOutputStream.j ava:1698)
at java.io.ObjectO utputStream.def aultWriteFields (ObjectOutputSt ream.java:1416)
at java.io.ObjectO utputStream.def aultWriteObject (ObjectOutputSt ream.java:398)
at java.lang.Throw able.writeObjec t(Throwable.jav a:679)
at sun.reflect.Nat iveMethodAccess orImpl.invoke0( Native Method)at sun.reflect.Nat iveMethodAccess orImpl.invoke(N ativeMethodAcce ssorImpl.java:8 5)
at sun.reflect.Nat iveMethodAccess orImpl.invoke(N ativeMethodAcce ssorImpl.java:5 8)
at sun.reflect.Del egatingMethodAc cessorImpl.invo ke(DelegatingMe thodAccessorImp l.java:60)
at java.lang.refle ct.Method.invok e(Method.java:3 91)
at java.io.ObjectS treamClass.invo keWriteObject(O bjectStreamClas s.java:967)
at java.io.ObjectO utputStream.wri teSerialData(Ob jectOutputStrea m.java:1387)
at java.io.ObjectO utputStream.wri teOrdinaryObjec t(ObjectOutputS tream.java:1338 )
at java.io.ObjectO utputStream.wri teObject0(Objec tOutputStream.j ava:1083)
at java.io.ObjectO utputStream.wri teFatalExceptio n(ObjectOutputS tream.java:1449 )
at java.io.ObjectO utputStream.wri teObject(Object OutputStream.ja va:312)
at com.ibm.nzna.pr ojects.common.s toredProc.Store dProcUtil.setOb jectInBlob(Stor edProcUtil.java :54)
at com.ibm.nzna.pr ojects.common.s toredProc.typeL istReader.TypeL istReader.readL ists(TypeListRe ader.java:166)

I get this exception when calling the stored procedure from within my java application. If I call the procedure from a DB2 command line (db2 call procedure QUEST.TypeListR eader (1, 1, ?, ?)), the procedure executes properly. This leads me to believe that the problem therefore lies in trying to get the Blob object from the stored procedure return record. Here are snippets of the code used to call the procedure:

This is the method that calls the procedure:
Expand|Select|Wrap|Line Numbers
  1.  
  2.    private boolean readTypeListUsingStoredProcedure ( TypeListRec typeListRec, SQLMethod sqlMethod ) {   
  3.   boolean rc = false ;
  4.  
  5.   try {
  6.  CallableStatement stmt              = sqlMethod.createStoredProc ( "QUEST.TypeListReader", 4 ) ;
  7.  TypeListReaderRec typeListReaderRec = null ;
  8.  
  9.             /*-----------------------------------------------------------*/
  10.             /*                                                           */
  11. /*   Set up our parameters                                   */
  12.             /*                                                           */
  13.             /*-----------------------------------------------------------*/
  14. stmt.setInt ( 1, languageInd ) ;                       // Our Language Indicator
  15. stmt.setInt ( 2, typeListRec.getTypeListInd() ) ;      // Our Type List to read
  16. stmt.registerOutParameter ( 3, Types.LONGVARBINARY ) ; // The return Lob for TypeListReaderRec
  17. stmt.registerOutParameter ( 4, Types.LONGVARBINARY ) ; // The return Lob for StoredProcRetRec
  18.  
  19.             /*-----------------------------------------------------------*/
  20.             /*                                                           */
  21.             /*   Execute                                                 */
  22.             /*                                                           */
  23.             /*-----------------------------------------------------------*/
  24.     stmt.execute() ;              // make the call to the stored procedure                       
  25.  
  26.             /*-----------------------------------------------------------*/
  27.             /*                                                           */
  28.             /*   Get the StoredProcRec from the Lob                      */
  29.             /*                                                           */
  30.             /*-----------------------------------------------------------*/
  31.             StoredProcRec retRec = (StoredProcRec)StoredProcUtil.getObjectFromStatement ( stmt, 4 ) ;
  32.  
  33.             if ( ( retRec != null ) && ( retRec.error ) ) {
  34.                LogSystem.log ( 1, retRec.errorStr ) ;
  35.             }
  36.  
  37.             /*-----------------------------------------------------------*/
  38.             /*                                                           */
  39.             /*   Otherwise continue                                      */
  40.             /*                                                           */
  41.             /*-----------------------------------------------------------*/
  42.             else {
  43.  
  44.                /*-----------------------------------------------------------*/
  45.                /*                                                           */
  46.                /*   Get our return object                                   */
  47.                /*                                                           */
  48.                /*-----------------------------------------------------------*/
  49.                typeListReaderRec = (TypeListReaderRec) StoredProcUtil.getObjectFromStatement ( stmt, 3 ) ;  
  50.                getInstance().setTypeList ( typeListRec.getTypeListInd(), typeListReaderRec.retVec ) ;                                   
  51.                rc = true ;
  52.             }
  53.  
  54.       } catch ( Exception e ) {
  55.          sqlMethod.rollBack() ;
  56.          LogSystem.log ( 1, e, false ) ;
  57.       }
  58.  
  59.       return ( rc ) ;
  60.  
  61.    }
  62.  
  63.  
  64.  
  65. This is the method that is defined as the procedure's external name (TypeListReader!readlists (...):
  66.  
  67.  
  68.  
  69.     public void readLists ( int languageInd, int typeListInd, Blob retTypeListReaderRec, Blob storedProcRetRec ) throws Exception  {                            
  70.  
  71.       try {
  72.  
  73.          /*-----------------------------------------------------------*/
  74.          /*                                                           */
  75.          /*   Get our connection to DB/2                              */
  76.          /*                                                           */
  77.          /*-----------------------------------------------------------*/
  78.          con = getConnection() ;         
  79.  
  80.          /*-----------------------------------------------------------*/
  81.          /*                                                           */
  82.          /*   Initialize our Type List Reader Record                  */
  83.          /*                                                           */
  84.          /*-----------------------------------------------------------*/
  85.          typeListReaderRec = new TypeListReaderRec () ;                                                    
  86.  
  87.          readLists ( languageInd, typeListInd, con, typeListReaderRec) ;
  88.  
  89.          /*-----------------------------------------------------------*/
  90.          /*                                                           */
  91.          /*   Write out our TypeListReaderRec                         */
  92.          /*                                                           */
  93.          /*-----------------------------------------------------------*/
  94.  
  95.  
  96.  
  97.  
  98. *** I create a new Blob object from COM.ibm.db2.app.Lob, then pass it to my setObjectInBlob method along with typeListReaderRec, which contains the data I want to pass back to the client ***
  99.  
  100.  
  101.  
  102.  
  103.          retTypeListReaderRec = Lob.newBlob() ;
  104.          StoredProcUtil.setObjectInBlob ( retTypeListReaderRec, typeListReaderRec );  //This is the method call that fails
  105.          set ( 3, retTypeListReaderRec ) ;
  106.  
  107.  
  108.       } catch ( Exception e ) {
  109.          StoredProcUtil.writeException ( e, returnRec ) ;
  110.       }
  111.  
  112.       /*-----------------------------------------------------------*/
  113.       /*                                                           */
  114.       /*   Commit                                                  */
  115.       /*                                                           */
  116.       /*-----------------------------------------------------------*/
  117.       con.commit() ;
  118.       con.close() ;
  119.  
  120.       /*-----------------------------------------------------------*/
  121.       /*                                                           */
  122.       /*   Write out our return information                        */
  123.       /*                                                           */
  124.       /*-----------------------------------------------------------*/
  125.       storedProcRetRec = Lob.newBlob() ;
  126.       StoredProcUtil.setObjectInBlob ( storedProcRetRec, returnRec ) ;
  127.  
  128.       set ( 4, storedProcRetRec ) ;
  129.  
  130.    }
  131.  
  132. This is the method that places the return object into the blob:
  133.  
  134.     public static void setObjectInBlob ( Blob blob, Object object ) throws Exception {
  135.         ObjectOutputStream s = new ObjectOutputStream ( blob.getOutputStream() ) ;
  136.  
  137.         s.writeObject ( object ) ;  // This is the line that actually fails
  138.         s.flush() ;
  139.         s.close() ;
  140.     }
  141.  
  142.  
  143. This is how TypeListReaderRec is defined (the object I am passing back to the client).  It is just a collection of Vector objects:
  144. package com.ibm.nzna.projects.common.storedProc.typeListReader ;
  145. import java.util.* ;
  146.  
  147. public class TypeListReaderRec implements java.io.Serializable {
  148.  
  149.     public Vector retVec = null ;
  150.  
  151.     public Vector countryCodeVec    = null ;
  152.     public Vector geographyVec      = null ;
  153.     public Vector docTypeVec        = null ;
  154.     public Vector docClassVec       = null ;
  155.     public Vector customViewVec     = null ;
  156.     public Vector workVec           = null ;
  157.     public Vector authVec           = null ;
  158.     public Vector metricVec         = null ;
  159.     public Vector languageVec       = null ;
  160.     public Vector fsVec             = null ;
  161.  
  162. } /* TypeListReaderRec */
Jun 16 '07 #1
1 2973
amgupta8
2 New Member
This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2.
Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and recompiling/executing the code with 1.4.1 (deploying the newly compiled stored procedure code as well).

This is the original exception that I got before I tried any code modifications:

java.io.IOExcep tion: invalid offset/length
at COM.ibm.db2.app .BlobOutputStre am.write(Lob.ja va:33 7)
at java.io.ObjectO utputStream$Blo ckDataOutputStr eam.w rite(ObjectOutp utStream.java:1 698)
at java.io.ObjectO utputStream.def aultWriteFields (Obje ctOutputStream. java:1416)
at java.io.ObjectO utputStream.def aultWriteObject (Obje ctOutputStream. java:398)
at java.lang.Throw able.writeObjec t(Throwable.jav a:679 )
at sun.reflect.Nat iveMethodAccess orImpl.invoke0( Nativ e Method)at sun.reflect.Nat iveMethodAccess orImpl.invoke(N ative MethodAccessorI mpl.java:85)
at sun.reflect.Nat iveMethodAccess orImpl.invoke(N ative MethodAccessorI mpl.java:58)
at sun.reflect.Del egatingMethodAc cessorImpl.invo ke(De legatingMethodA ccessorImpl.jav a:60)
at java.lang.refle ct.Method.invok e(Method.java:3 91)
at java.io.ObjectS treamClass.invo keWriteObject(O bject StreamClass.jav a:967)
at java.io.ObjectO utputStream.wri teSerialData(Ob jectO utputStream.jav a:1387)
at java.io.ObjectO utputStream.wri teOrdinaryObjec t(Obj ectOutputStream .java:1338)
at java.io.ObjectO utputStream.wri teObject0(Objec tOutp utStream.java:1 083)
at java.io.ObjectO utputStream.wri teFatalExceptio n(Obj ectOutputStream .java:1449)
at java.io.ObjectO utputStream.wri teObject(Object Outpu tStream.java:31 2)
at com.ibm.nzna.pr ojects.common.s toredProc.Store dProc Util.setObjectI nBlob(StoredPro cUtil.java:54)
at com.ibm.nzna.pr ojects.common.s toredProc.typeL istRe ader.TypeListRe ader.readLists( TypeListReader. java: 166)

Please let me know if more clarifications are required
Jun 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
10676
by: randy.p.ho | last post by:
Using JDBC, is there a way to call a stored procedure with multiple return values? Thanks.
2
5288
by: Marc Stiegele | last post by:
Hello, I have a problem with the IBM DB2 UDB XML Extender. I`m working on a iSeries 400 server (AS/400, V5R1) with a integrated DB2 (my client is NT 4.0 Service Pack 1 with JDK1.1.8). I want to create XML files out of the DB2 data using the XML collections method and SQL mapping. I successfully enabled my database, put the collection.dtd into DTD_REF, created a DAD file and enabled the collection (xcolltest01) using the OS/400 command...
5
2059
by: Alex | last post by:
Hi all, I'm sure this is really really easy but I do need some help. I'm writing a java stored prcedure to manage the assignment of IP addresses to mac addresses for a network device database I've got. Basically a user fills in a template detailing information about themselves, the location of the pc and its mac address. The SP takes this input info and scans a database table that stores the assigned ip addresses in a subnet looking...
2
9244
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
0
2404
by: Roman Prigozhin | last post by:
HI All, I have a problem with calling stored procedure in multithreaded environment. This procedure utilizes session table to collect data and cursor to return it back to java application . When 10 threads are trying to use the same stored procedure, once one of the thread finishes up and returns connection back to the pool I'm getting exception from all other 9 stored procedures : com.ibm.db2.jdbc.app.DB2DBException: SC_PE00003 in...
4
3994
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine but when he runs the stored procedure, he gets the following error message. "SYSPROC".CSGCSB54 - Run started. Data returned in result sets is limited to the first 100 rows. Data returned in result set columns is limited to the first 20...
4
3586
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In the corresponding input field (text box) the user enters a new category order which gets stored in the...
3
3745
by: mgsmario | last post by:
Hi Guys I have an ASP application that connects to an Oracle database, right now I'm trying to connect this same ASP application to a DB2 database (Express-C, version 9.5.0). I'm in the process of trying to translate all the programing withing asp pages, so, can interact smoothly with db2. Now, I have problems trying to use a stored procedure (db2) and call it from my asp application. Here's part of my procedure:
0
2109
by: mgsmario | last post by:
Hi Guys I have an ASP application that connects to an Oracle database, right now I'm trying to connect this same ASP application to a DB2 database (Express-C, version 9.5.0). I'm in the process of trying to translate all the programing withing asp pages, so, can interact smoothly with db2. Now, I have problems trying to use a stored procedure (db2) and call it from my asp application. Here's part of my procedure:
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.