Java

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



Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old January 5th, 2017, 11: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?

Code:
Code:
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.
    cstmt.execute();


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


Error Trace:
Code:
 java.sql.DataTruncation: Data truncation at com.ibm.as400.access.AS400JDBCPreparedStatement.te  stDataTruncation(AS400JDBCPreparedStatement.java:3  450) at com.ibm.as400.access.AS400JDBCPreparedStatement.se  tValue(AS400JDBCPreparedStatement.java:3361) at com.ibm.as400.access.AS400JDBCPreparedStatement.se  tString(AS400JDBCPreparedStatement.java:2999) at com.ibm.as400.access.AS400JDBCCallableStatement.se  tString(AS400JDBCCallableStatement.java:3082) at org.jboss.jca.adapters.jdbc.WrappedCallableStateme  nt.setString(WrappedCallableStatement.java:1563) at com.ssss.ssjtracdbws.dao.SSJTracDBWSDAO.submitNewR  equestJSON(SSJTracDBWSDAO.java:617) at com.ssss.ssjtracdbws.webservices.SSJTracDBService.  submitNewRequestJSON(SSJTracDBService.java:154) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ  e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native  MethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De  legatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(  MethodInjectorImpl.java:167) at org.jboss.resteasy.core.ResourceMethod.invokeOnTar  get(ResourceMethod.java:269) at org.jboss.resteasy.core.ResourceMethod.invoke(Reso  urceMethod.java:227) at org.jboss.resteasy.core.ResourceMethod.invoke(Reso  urceMethod.java:216) at org.jboss.resteasy.core.SynchronousDispatcher.getR  esponse(SynchronousDispatcher.java:542) at org.jboss.resteasy.core.SynchronousDispatcher.invo  ke(SynchronousDispatcher.java:524) at org.jboss.resteasy.core.SynchronousDispatcher.invo  ke(SynchronousDispatcher.java:126) at org.jboss.resteasy.plugins.server.servlet.ServletC  ontainerDispatcher.service(ServletContainerDispatc  her.java:208) at org.jboss.resteasy.plugins.server.servlet.HttpServ  letDispatcher.service(HttpServletDispatcher.java:5  5) at org.jboss.resteasy.plugins.server.servlet.HttpServ  letDispatcher.service(HttpServletDispatcher.java:5  0) at javax.servlet.http.HttpServlet.service(HttpServlet  .java:847) at org.apache.catalina.core.ApplicationFilterChain.in  ternalDoFilter(ApplicationFilterChain.java:295) at org.apache.catalina.core.ApplicationFilterChain.do  Filter(ApplicationFilterChain.java:214) at org.apache.catalina.core.StandardWrapperValve.invo  ke(StandardWrapperValve.java:231) at org.apache.catalina.core.StandardContextValve.invo  ke(StandardContextValve.java:149) at org.jboss.as.web.security.SecurityContextAssociati  onValve.invoke(SecurityContextAssociationValve.jav  a:169) at org.apache.catalina.core.StandardHostValve.invoke(  StandardHostValve.java:145) at org.apache.catalina.valves.ErrorReportValve.invoke  (ErrorReportValve.java:97) at org.apache.catalina.valves.AccessLogValve.invoke(A  ccessLogValve.java:559) at org.apache.catalina.core.StandardEngineValve.invok  e(StandardEngineValve.java:102) at org.apache.catalina.connector.CoyoteAdapter.servic  e(CoyoteAdapter.java:340) at org.apache.coyote.http11.Http11NioProcessor.proces  s(Http11NioProcessor.java:353) at org.apache.coyote.http11.Http11NioProtocol$Http11C  onnectionHandler.process(Http11NioProtocol.java:91  1) at org.apache.tomcat.util.net.NioEndpoint$ChannelProc  essor.run(NioEndpoint.java:920) at java.util.concurrent.ThreadPoolExecutor.runWorker(  ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run  (ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Reply With Quote
Reply

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 - 2017, Jelsoft Enterprises Ltd.

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