VARCHAR2(1000) limited to 100 chars only
<p>When trying to store in an Oracle SQL table a string of more than 100 chars, while the field limitation is 1000 bytes which I understood is ~1000 English chars, I'm getting out of bounds exception:</p>
<p><code>StringIndexOutOfBoundsException: String index out of range: -3</code></p>
<p>What might be the cause for this low limitation?</p>
<p>Thanks!</p>
<p><strong>EDIT :</strong></p>
<p>The code where the error occurs is (see <a href="https://chat.stackoverflow.com/rooms/118875/discussion-between-jonathon-ogden-and-batman">chat</a>):</p>
<pre><code>// Commenting the existing code, because for sensitive information
// toString returns masked data
int nullSize = 5;
int i = 0;

// removing '[' and ']', signs and fields with 'null' value and also add
// ';' as delimiter.
while (i != -1) {
    int index1 = str.indexOf('[', i);
    int index2 = str.indexOf(']', i + 1);
    i = index2;
    if (index2 != -1 &amp;&amp; index1 != -1) {
        int index3 = str.indexOf('=', index1);
        if (index3 + nullSize &gt; str.length() || !str.substring(index3 + 1, index3 + nullSize).equals(&quot;null&quot;)) {
            String str1 = str.substring(index1 + 1, index2);
            concatStrings = concatStrings.append(str1);
            concatStrings = concatStrings.append(&quot;;&quot;);
        }
    }
}
</code></pre>