ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aravind.duraipa...@jpmchase.com
Subject Re: Sybase - IBatis Null Pointer Error
Date Thu, 18 Jan 2007 16:41:36 GMT
Hi Jeff,
        Thanks a TON..... I set the IGNORE_DONE_IN_PROC to true and now i 
am getting the resultset Back...Thanks for all ur Help....

Regards,
Aravind Duraipandi
PCS ITS
Phone:(614)-213-4722
Email: Aravind.Duraipandi@jpmchase.com
Pager: 8773830942@skytel.com



"Jeff Butler" <jeffgbutler@gmail.com> 
01/18/2007 11:24 AM
Please respond to
user-java@ibatis.apache.org


To
user-java@ibatis.apache.org
cc

Subject
Re: Sybase - IBatis Null Pointer Error






In your JDBC example you are using OUT parameters, but this is not what 
you've configured in iBATIS.  I'm getting a little lost in all the 
different versions of things you are showing - let's try to stick to one 
version of the code and SP. 
 
Nonetheless, you probably should try the IGNORE_DONE_IN_PROC driver 
setting.  I'll bet that all the internediate selects in your SP are being 
returned as result sets and this is confusing iBATIS.
 
Jeff Butler

 
On 1/18/07, aravind.duraipandi@jpmchase.com <
aravind.duraipandi@jpmchase.com > wrote: 

Hi Jeff, 
        Thanks for ur Response ...But the following is Working fine with 
the Stored Procedures which are having only Select Statements the 
following is the working mapping 


        <resultMap id="getAssetNameResult" class ="Asset"> 
                <result property= "assetId" column="ASSET_ID" /> 
                <result property="assetName" column ="ASSET_SHRT_NM"/> 
        </resultMap> 

        <parameterMap id= "getAssetNameParam"  class="Asset" > 
                <parameter property="assetId" jdbcType = "VARCHAR" 
javaType= "java.lang.String" mode="IN" /> 
        </parameterMap > 

        <procedure id="GET_ASSET_NAME" parameterMap ="getAssetNameParam" 
resultMap= "getAssetNameResult"> 
                { call sp_getAssetName(?)} 
        </procedure> 


The above mentioned thing is working fine...Returning me the Object and i 
am able to access the Object and set it back in the front end.... 

SP for the Above mapping is 

create proc sp_getAssetName 
        @p_asset_id varchar(12) 
as 
select         Asset.ASSET_ID, 
                Asset.ASSET_SHRT_NM 
from 
        dbo.ASSET Asset 
Where 
        ASSET_ID = @p_asset_id         
return 


But Only when the Stored Procedure is having Insert and Select Statements 
the object is null 

And Moreover i tried running the insert Stored Procedure thru 
Callablestatment. I am getting back the Resultset 

The Code for the Callable Statement is below 


Connection con = null; 
  CallableStatement stmt = null; 
  ResultSet result = null; 
  try { 
    InitialContext ctx = new InitialContext(); 
    DataSource ds = (DataSource) ctx.lookup("jdbc/nsadev"); 
    con = ds.getConnection(); 
    stmt = con.prepareCall("{CALL sp_savetransaction(?)}"); 
    stmt.setString(1,"100"); 
    /*stmt.setString(2, "testuser"); 
    stmt.registerOutParameter(3, Types.VARCHAR); 
    stmt.registerOutParameter(4, Types.VARCHAR);*/ 
    result = stmt.executeQuery(); 
  } catch (NamingException nex) { 
   System.err.println("Naming Error: " + nex.getMessage ());     
  } catch (SQLException sqlex) { 
          sqlex.printStackTrace(); 
   /*System.err.println ("SQL Error: " + sqlex.getMessage()); 
   System.out.println("Return Value:" + stmt.getString(1)); 
   System.out.println ("ErrorCode:" + stmt.getString(3)); 
   System.out.println("Error Message:" + stmt.getString(4));*/ 
  }   
 if(result !=null) { 
         result.next(); 
  System.err.println(result.getString("TXN_ID")); 
 } 
 else { 
         System.err.println("I am Inside NULL"); 
 } 

So if there is a problem in Sybase it should not be working thru IBatis 
and also the above CallableStatment..But it is not the Case ..It is 
working fine when using CallableStatement..I will also look into the 
IGNORE_DONE_IN_PROC .... But as far as Database is concerned the Row is 
Inserted and i am able to see the Data in the Database..... Please 
Advice... 

Thanks for ur Help 


Regards,
Aravind Duraipandi
PCS ITS
Phone:(614)-213-4722
Email: Aravind.Duraipandi@jpmchase.com
Pager: 8773830942@skytel.com 


"Jeff Butler" <jeffgbutler@gmail.com> 
01/18/2007 10:31 AM 

Please respond to
user-java@ibatis.apache.org 



To
user-java@ibatis.apache.org 
cc

Subject
Re: Sybase - IBatis Null Pointer Error









You have every parameter delcared as input only - is that right? 
 
Also, and I'm no ASE expert, I do remember something wierd about ASE 
regarding a driver setting IGNORE_DONE_IN_PROC.  That might be worth 
looking into. 
 
Jeff Butler 



On 1/17/07, aravind.duraipandi@jpmchase.com < 
aravind.duraipandi@jpmchase.com > wrote: 

Hi, 
       We are Building a Project  where we use SYBASE and IBATIS. We are 
mapping the Objects Directly in the SQLMaps. Whenever i am doing an Select 
Statement inside the Stored Procedure i am getting back the Object. But 
When i have Insert Statement and then the Select Statement in the Stored 
Procedure a NULL Object is returned. We are getting a NULL PONTER 
Exception While trying to access the Object. I am not Sure why this is 
Happening. Can someone help me on this.. 



SQL Map has the Following 


        <!--Procedure to Save in Transaction Master STARTS --> 
       < resultMap id="saveTransactionResult" class ="Transaction"> 
               <result property = "transactionId" column= "TXN_ID" /> 
       </ resultMap > 

        <parameterMap id= "saveTransactionParam"  class ="Transaction" > 
               < parameter property= "assetInformation.price" jdbcType = 
"INTEGER" javaType ="java.lang.String" mode= "IN"/> 
               < parameter property = "profile.profileId" jdbcType = 
"VARCHAR" javaType="java.lang.String" mode="IN"/> 
               <parameter property ="transactionType" jdbcType = "VARCHAR" 
javaType="java.lang.String" mode="IN"/> 
               <parameter property ="assetInformation.draftFlag" jdbcType 
= "VARCHAR" javaType="java.lang.String" mode="IN"/> 
               <parameter property ="account.accountNumber" jdbcType = 
"VARCHAR" javaType="java.lang.String" mode="IN"/> 
               <parameter property ="assetInformation.assetId" jdbcType = 
"VARCHAR" javaType="java.lang.String" mode="IN"/> 
               <parameter property ="userId" jdbcType = "VARCHAR" javaType
="java.lang.String" mode="IN"/> 
       </parameterMap> 

       <procedure id ="SAVE_TRANSACTION" parameterMap = 
"saveTransactionParam" resultMap= "saveTransactionResult" > 
               { call sp_savetransaction(?,?,?,?,?,?,?) } 
       </procedure > 


The SP code is the Following 


create proc sp_savetransaction1 
       @P_TXN_AMOUNT_I varchar(20) , 
       @P_PRFL_ID_I varchar(20) , 
       @P_TXN_TYP_CD_I varchar(20) , 
       @P_DRAFT_FL_I   varchar(20) , 
       @P_ACCT_NB_I        varchar(20) , 
       @P_ASSET_ID_I        varchar(20) , 
       @P_LOG_USER_I         varchar(20) 
as 
       declare  @v_txn_axn_id int 
       declare  @v_txn_typ_id int 
       declare  @v_txn_sts_id int 
       declare  @v_txn_id int 
       declare  @v_txnwf_id int 
 
       --SELECT @P_TXN_TYP_CD_I AS 'YYYY' 
 
       select @v_txn_typ_id = TXN_TYPE_ID from TXN_TYPE WHERE TXN_TYPE_CD 
=  @P_TXN_TYP_CD_I 
 
       IF @P_DRAFT_FL_I = 'Y' 
               select   @v_txn_sts_id = TXN_STS_ID from TXN_STS WHERE 
TXN_STS_CD = 'DRFT' 
       ELSE 
               begin 
                       select   @v_txn_axn_id = TXN_AXN_ID from 
TXN_ACTION_MASTER WHERE TXN_AXN_CD = 'INTD' 
                       select   @v_txn_sts_id = TXN_STS_ID from TXN_STS 
WHERE TXN_STS_CD = 'INTD'         
               end 
 
       INSERT INTO TXN_MASTER 
 
(TXN_TYPE_ID,TXN_STS_ID,PRFL_ID,TXN_DT,TXN_AMOUNT,DRFT_FLAG,CRE_USR_ID,CRE_USR_TS,UPDT_USR_ID,UPDT_TS,ACCT_NB

,ASSET_ID) 
       VALUES 
       (@v_txn_typ_id,@v_txn_sts_id ,cast(@P_PRFL_ID_I as int) 
,GETDATE(),cast(@P_TXN_AMOUNT_I as numeric),@P_DRAFT_FL_I 
,@P_LOG_USER_I,GETDATE(),NULL,NULL, @P_ACCT_NB_I,@P_ASSET_ID_I) 
 
       SET @v_txn_id = @@IDENTITY 
 
       IF @P_DRAFT_FL_I <> 'Y' 
               begin                                 
                               INSERT INTO TXN_WKFLW VALUES( @v_txn_id 
,@v_txn_axn_id 
,GETDATE(),@P_LOG_USER_I,NULL,@v_txn_axn_id,NULL,@P_LOG_USER_I,GETDATE(),NULL,NULL) 

               end 
 
       SELECT @v_txn_id as TXN_ID 
 
return 

Please let me know how to proceed with this Error. 


Regards,
Aravind Duraipandi
PCS ITS
Phone:(614)-213-4722
Email: Aravind.Duraipandi@jpmchase.com
Pager: 8773830942@skytel.com 


This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or 
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and
any attachments are believed to be free of any virus or other 
defect that might affect any computer system into which it is 
received and opened, it is the responsibility of the recipient to
ensure that it is virus free and no responsibility is accepted by
JPMorgan Chase & Co., its subsidiaries and affiliates, as 
applicable, for any loss or damage arising in any way from its use. 
If you received this transmission in error, please immediately
contact the sender and destroy the material in its entirety,
whether in electronic or hard copy format. Thank you. 


Mime
View raw message