title: PostgreSQL equivalent of oracle.sql.BLOB in Java
body: <p>I have the following code using <code>oracle.sql.BLOB</code></p>
  
  <pre><code>BLOB b = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
  //conn is a PostgreSQL connection (java.sql.Connection object)
  b.setBytes(1, someString.getBytes());
  ps.setBlob(++i, b); //ps is a PreparedStatement
  </code></pre>
  
  <p>Obviously it wouldn't work because <code>createTemporary</code> expects an Oracle connection.</p>
  
  <ol>
  <li><p>What is the equivalent way of achieving this using a Postgres connection? I understand the Postgres equivalent of <em>Blob</em> is <strong>ByteA</strong>. The target column is a <code>bytea</code> column. Can I just do the following? Or is there a proper way of achieving the same effect?</p>
  
  <pre><code>ps.setBytes(++i, someString.getBytes());
  </code></pre></li>
  <li><p>Also, how do I make the Oracle-specific code DB-vendor-independent? (avoiding the use of <code>oracle.sql.BLOB</code> even if it is an Oracle connection)</p></li>
  </ol>