title: Storing/retrieving BYTEA and BLOB with Java/Scala: "java.sql.SQLFeatureNotSupportedException"
body: <p>The situation is as follows: I'm trying to store/retrieve byte[] arrays and BLOBS in a PostgreSQL database. </p>
  
  <p>I'm using Scala Play with Anorm, but for dealing with BYTEA and BLOB's I've regressed to using plain old java.sql.Connection API and roughly followed this description: </p>
  
  <p><a href="http://jdbc.postgresql.org/documentation/80/binary-data.html" rel="nofollow">http://jdbc.postgresql.org/documentation/80/binary-data.html</a></p>
  
  <p>My code looks as follows:</p>
  
  <pre><code>def saveSmallImage(id: String, img: SmallImage): Unit = {
    DB.withConnection { implicit conn =&gt;
  
    val ps = conn.prepareStatement(
      "INSERT INTO SmallImage(id, mimeType, image) VALUES (?, ?, ?)")
    ps.setString(1, id)
    ps.setString(2, img.mimeType)
    ps.setBinaryStream(3, img.binaryStream, img.length)
    ps.executeUpdate()
    ps.close()
  }
  } 
  </code></pre>
  
  <p>where 'image' column is of type BYTEA, img.binaryStream is of type InputStream.</p>
  
  <p>I'm getting this error:</p>
  
  <pre><code>java.sql.SQLFeatureNotSupportedException: Method 
  org.postgresql.jdbc4.Jdbc4PreparedStatement.
    setBinaryStream(int, InputStream, long) 
  is not yet implemented.
  </code></pre>
  
  <p>I have the following dependency in my build.sbt:</p>
  
  <pre><code>"postgresql" % "postgresql" % "9.1-901-1.jdbc4"
  </code></pre>
  
  <p>(this corresponds to groupId, artifactId, version in maven POM-files). This seems to be the most recent one. The Postgres Manual tells me, that this feature has been present since PostgreSQL version 7.2.</p>
  
  <p>What's going on? Is PostgreSQL/JDBC somehow deprecated and no longer maintained?
  Should I take another version to make it work?
  Or is SQL completely dead, and I should switch to some other database? 
  Is it somehow a generally bad idea to use Postgres with Java?
  Could it somehow matter that my postgres version is 9.3 but I'm using JDBC 9.1-x?</p>
  
  <p>I would be very thankful if anyone tells me what I'm doing wrong and how to make it work.</p>
  
  <p>PS:
  ... Tried to git-clone pgjdbc. It requires ant 1.4.1 to build. This ant version is ~8 years old and no longer available at the website of the Apache foundation. Isn't it kind of eerie?</p>