# Database Discussions > IBM DB2 >  Data truncation error while setting INOUT CHARACTER(2) parameter in Stored Procedure

## skrrao

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:


```
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:



```
Num Mode Name DataType Length
1 INOUT 5506ETT CHARACTER 2
2 INOUT 5506NWR CHARACTER 10
3 INOUT 5506STS CHARACTER 3
```

Error Trace:

ERROR TRACE: 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)

----------

