public void setNClob(int idx, NClob nclob) throws SQLException {
   try {
     addMementoEntry("setNClob", new Class[] {NClob.class}, idx, nclob);
     wrapped.setNClob(idx, nclob);
   } catch (SQLException e) {
     throw new UcanaccessSQLException(e);
   }
 }
 public void setNClob(int idx, Reader reader, long length) throws SQLException {
   try {
     reader = markableReader(reader, length);
     addMementoEntry("setNClob", new Class[] {Reader.class, Long.TYPE}, idx, reader, length);
     wrapped.setNClob(idx, reader, length);
     resetReader(reader);
   } catch (SQLException e) {
     throw new UcanaccessSQLException(e);
   }
 }
 public void setNClob(int parameterIndex, Reader reader) throws SQLException {
   String methodCall = "setNClob(" + parameterIndex + ", " + reader + ")";
   argTraceSet(parameterIndex, "(Reader)", "<Reader>");
   try {
     realPreparedStatement.setNClob(parameterIndex, reader);
   } catch (SQLException s) {
     reportException(methodCall, s);
     throw s;
   }
   reportReturn(methodCall);
 }
 public void setNClob(int parameterIndex, NClob value) throws SQLException {
   String methodCall = "setNClob(" + parameterIndex + ", " + value + ")";
   argTraceSet(parameterIndex, "(NClob)", "<NClob>");
   try {
     realPreparedStatement.setNClob(parameterIndex, value);
   } catch (SQLException s) {
     reportException(methodCall, s);
     throw s;
   }
   reportReturn(methodCall);
 }
Ejemplo n.º 5
0
 @Override
 protected void setNullSafeValue(
     PreparedStatement statement, NClob value, int index, Field field, Map<String, Object> options)
     throws SQLException {
   statement.setNClob(index, value);
 }
Ejemplo n.º 6
0
  private void testClob(int length) throws Exception {
    Random r = new Random(length);
    char[] data = new char[length];

    // Unicode problem:
    // The UCS code values 0xd800-0xdfff (UTF-16 surrogates)
    // as well as 0xfffe and 0xffff (UCS non-characters)
    // should not appear in conforming UTF-8 streams.
    // (String.getBytes("UTF-8") only returns 1 byte for 0xd800-0xdfff)
    for (int i = 0; i < length; i++) {
      char c;
      do {
        c = (char) r.nextInt();
      } while (c >= 0xd800 && c <= 0xdfff);
      data[i] = c;
    }
    Clob c = conn.createClob();
    Writer out = c.setCharacterStream(1);
    out.write(data, 0, data.length);
    out.close();
    stat.execute("delete from test");
    PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?)");

    prep.setInt(1, 1);
    prep.setClob(2, c);
    prep.execute();

    c = conn.createClob();
    c.setString(1, new String(data));
    prep.setInt(1, 2);
    prep.setClob(2, c);
    prep.execute();

    prep.setInt(1, 3);
    prep.setCharacterStream(2, new StringReader(new String(data)));
    prep.execute();

    prep.setInt(1, 4);
    prep.setCharacterStream(2, new StringReader(new String(data)), -1);
    prep.execute();

    NClob nc;
    nc = conn.createNClob();
    nc.setString(1, new String(data));
    prep.setInt(1, 5);
    prep.setNClob(2, nc);
    prep.execute();

    prep.setInt(1, 5);
    prep.setNClob(2, new StringReader(new String(data)));
    prep.execute();

    prep.setInt(1, 6);
    prep.setNClob(2, new StringReader(new String(data)), -1);
    prep.execute();

    prep.setInt(1, 7);
    prep.setNString(2, new String(data));
    prep.execute();

    ResultSet rs;
    rs = stat.executeQuery("select * from test");
    rs.next();
    Clob c2 = rs.getClob(2);
    assertEquals(length, c2.length());
    String s = c.getSubString(1, length);
    String s2 = c2.getSubString(1, length);
    while (rs.next()) {
      c2 = rs.getClob(2);
      assertEquals(length, c2.length());
      s2 = c2.getSubString(1, length);
      assertEquals(s, s2);
    }
  }
 public void setNClob(int parameterIndex, Reader reader) throws SQLException {
   delegate.setNClob(parameterIndex, reader);
 }
 public void setNClob(int parameterIndex, NClob value) throws SQLException {
   delegate.setNClob(parameterIndex, value);
 }
Ejemplo n.º 9
0
 @Override
 public void setNClob(int parameterIndex, Reader x, long length) throws SQLException {
   stmt.setNClob(parameterIndex, x, length);
   logValue(parameterIndex, x == null ? null : "<NClob>");
 }
Ejemplo n.º 10
0
 @Override
 public void setNClob(int parameterIndex, NClob x) throws SQLException {
   stmt.setNClob(parameterIndex, x);
   logValue(parameterIndex, x == null ? null : "<NClob>");
 }