Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
Unread Tutorialized Forums Sponsor:
Old January 5th, 2017, 10:10 AM
skrrao skrrao is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
Join Date: Jan 2017
Posts: 1 skrrao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 22 sec
Reputation Power: 0
Data truncation error while setting INOUT CHARACTER(2) parameter in Stored Procedure

I'm calling a stored procedure in JAVA which has INOUT parameters. Database is DB2. Type is CHARACTER(2). I'm getting Data Truncation error while setting the variable. Could you please let me know where I'm going wrong and how I can set the value of the parameter using a variable without causing exception?

String cstmt_str = "CALL " + storedProcName + "(?,?,?)";
 String ett="JD"; String nwReasonCode=" ";Connection conn = null;CallableStatement cstmt = null;

    cstmt = conn.prepareCall(cstmt_str);

    cstmt.registerOutParameter("5506ETT", Types.CHAR);
    //cstmt.setString("5506ETT","JD"); does not give a problem
    cstmt.setString("5506ETT",ett); //Data truncation Exception occurs here.

    cstmt.registerOutParameter("5506NWR", Types.CHAR);
    cstmt.setString("5506NWR", nwReasonCode);//Doesnt give a problem

    cstmt.registerOutParameter("5506STS", Types.CHAR);
    cstmt.setString("5506STS", "PND");// If I set the value directly instead of variable, it does not complain. If I use a variable that holds the value, it gives the same exception here too.

Stored Procedure Signature:
Num Mode    Name      DataType    Length
1      INOUT 5506ETT   CHARACTER 2
3      INOUT 5506STS  CHARACTER 3 

Error Trace:
 java.sql.DataTruncation: Data truncation at  stDataTruncation(  450) at  tValue( at  tString( at  tString( at org.jboss.jca.adapters.jdbc.WrappedCallableStateme  nt.setString( at com.ssss.ssjtracdbws.dao.SSJTracDBWSDAO.submitNewR  equestJSON( at com.ssss.ssjtracdbws.webservices.SSJTracDBService.  submitNewRequestJSON( at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ  e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native at sun.reflect.DelegatingMethodAccessorImpl.invoke(De at java.lang.reflect.Method.invoke( at org.jboss.resteasy.core.MethodInjectorImpl.invoke( at org.jboss.resteasy.core.ResourceMethod.invokeOnTar  get( at org.jboss.resteasy.core.ResourceMethod.invoke(Reso at org.jboss.resteasy.core.ResourceMethod.invoke(Reso at org.jboss.resteasy.core.SynchronousDispatcher.getR  esponse( at org.jboss.resteasy.core.SynchronousDispatcher.invo  ke( at org.jboss.resteasy.core.SynchronousDispatcher.invo  ke( at org.jboss.resteasy.plugins.server.servlet.ServletC  ontainerDispatcher.service(ServletContainerDispatc at org.jboss.resteasy.plugins.server.servlet.HttpServ  letDispatcher.service(  5) at org.jboss.resteasy.plugins.server.servlet.HttpServ  letDispatcher.service(  0) at javax.servlet.http.HttpServlet.service(HttpServlet  .java:847) at  ternalDoFilter( at  Filter( at org.apache.catalina.core.StandardWrapperValve.invo  ke( at org.apache.catalina.core.StandardContextValve.invo  ke( at  onValve.invoke(SecurityContextAssociationValve.jav  a:169) at org.apache.catalina.core.StandardHostValve.invoke( at org.apache.catalina.valves.ErrorReportValve.invoke  ( at org.apache.catalina.valves.AccessLogValve.invoke(A at org.apache.catalina.core.StandardEngineValve.invok  e( at org.apache.catalina.connector.CoyoteAdapter.servic  e( at org.apache.coyote.http11.Http11NioProcessor.proces  s( at org.apache.coyote.http11.Http11NioProtocol$Http11C  onnectionHandler.process(  1) at$ChannelProc at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$  ( at

Reply With Quote

Viewing: Tutorialized ForumsWeb Design & DevelopmentJava > Data truncation error while setting INOUT CHARACTER(2) parameter in Stored Procedure

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap