title: Java string .length() X does not fit into DB2 varchar(X)
body: <p>I observed one issue that, I am trying to save a record in DB2 database with fields having length check in Java code. I have kept length check exactly equal to database varchar limit. And trying to save but getting SQL Exception DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null, DRIVER=3.57.82; </p>
  
  <p>Then I reduced the length (truncated) the length smaller than the database size. Truncated to substring (0, 900) apprx for varchar(1000).</p>
  
  <p>Please let me what could be the reason of the same. Is it related to character encoding?
  How it needs to be handled? </p>
  
  <p>What is default character encoding applied to String (input from request parameter of a text area field) and corresponding no. of bytes?</p>