title: Is it safe to use JDBC setString() to store CLOB data type with Oracle database?
body: <p>I have a need to store a large string into Oracle database the length of which would be at most 10000 bytes. I understand that there is some configuration in Oracle 12c that can increase the 4000 byte limit of varchar2.  But I do not have the option to use that configuration.</p>
  
  <p>So I am inclined to use the CLOB data type.  I have no previous experience in using CLOB.  So I have my concerns.</p>
  
  <p>I saw the following on SO</p>
  
  <p><a href="https://stackoverflow.com/questions/5549450/java-how-to-insert-clob-into-oracle-database">Java: How to insert CLOB into oracle database</a></p>
  
  <p>I did not want to use any oracle package to handle the CLOB type.  My question is, is the following safe enough for my purpose?</p>
  
  <p>To store:</p>
  
  <pre><code>try {
      String myclobstring = "xx ........"; 
      String sql = "Insert into mytable (clobfield) values (?)";
      Statement stmt = conn.prepareStatement(sql);
      stmt.setString(1, myclobstring); 
      .
      .
  }
  </code></pre>
  
  <p>To Retrieve:</p>
  
  <pre><code>try {
      String sql = "select clobfield from mytable";
      stmt = conn.createStatement();
      ResultSet result = stmt.executeQuery(sql);
      String s = result.getString ("clobfield');
      .
      .
  }
  </code></pre>