PgSQLXML implements SQLXML { @Override public synchronized Writer setCharacterStream() throws SQLException { checkFreed(); initialize(); active = true; stringWriter = new StringWriter(); return stringWriter; } PgSQLXML(BaseConnection conn);  PgSQLXML(BaseConnection conn, @Nullable String data); private  PgSQLXML(BaseConnection conn, @Nullable String data, boolean initialized); @Override synchronized void free(); @Override synchronized @Nullable InputStream getBinaryStream(); @Override synchronized @Nullable Reader getCharacterStream(); @Override synchronized T getSource(@Nullable Class<T> sourceClass); @Override synchronized @Nullable String getString(); @Override synchronized OutputStream setBinaryStream(); @Override synchronized Writer setCharacterStream(); @Override synchronized T setResult(Class<T> resultClass); @Override synchronized void setString(String value);  }
@Test public void setCharacterStream() throws Exception { String exmplar = "<x>value</x>"; SQLXML pgSQLXML = con.createSQLXML(); Writer writer = pgSQLXML.setCharacterStream(); writer.write(exmplar); PreparedStatement preparedStatement = con.prepareStatement("insert into xmltab values (?)"); preparedStatement.setSQLXML(1, pgSQLXML); preparedStatement.execute(); Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery("select * from xmltab"); assertTrue(rs.next()); SQLXML result = rs.getSQLXML(1); assertNotNull(result); assertEquals(exmplar, result.getString()); }