Examples of Clob


Examples of java.sql.Clob

            bytes = value.getBytes(this.encoding);
          }
          break;
       
        case PG_TYPE_TEXT:
          Clob clob = rs.getClob(column);
          if (clob != null) {
            bytes = ObjectConverterUtil.convertToByteArray(new ReaderInputStream(clob.getCharacterStream(), this.encoding), this.maxLobSize);
          }             
          break;
         
        case PG_TYPE_BYTEA:
          Blob blob = rs.getBlob(column);
View Full Code Here

Examples of java.sql.Clob

   
    static final String getString(Object value) throws SQLException {
      if (value instanceof SQLXML) {
        return ((SQLXML)value).getString();
      } else if (value instanceof Clob) {
        Clob c = (Clob)value;
        return c.getSubString(1, c.length()>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)c.length());
      }
      return transform(value, String.class, "String"); //$NON-NLS-1$
    }
View Full Code Here

Examples of java.sql.Clob

        XMLType xml = (XMLType)object;
        r = xml.getCharacterStream();
        Type type = xml.getType();
        convertReader(writer, eventWriter, r, type);
      } else if (object instanceof Clob) {
        Clob clob = (Clob)object;
        r = clob.getCharacterStream();
        convertReader(writer, eventWriter, r, Type.TEXT);
      } else {
        String val = convertToAtomicValue(object).getStringValue();
        eventWriter.add(eventFactory.createCharacters(val));
      }
View Full Code Here

Examples of java.sql.Clob

        if (targetType.isAssignableFrom(currentType)) {
            return o;
        }
        if (targetType == String.class) {
            if (Clob.class.isAssignableFrom(currentType)) {
                Clob c = (Clob) o;
                try {
                    Reader r = c.getCharacterStream();
                    return readStringAndClose(r, -1);
                } catch (Exception e) {
                    throw new RuntimeException("Error converting CLOB to String: " + e.toString(), e);
                }
            }
View Full Code Here

Examples of java.sql.Clob

                        "c_.CLOB_DATA as CLOB3_0_0_ from CLOB_ENTITY c_ where c_.ID=?");
        prep2.setLong(1, 1);
        ResultSet rs1 = prep2.executeQuery();
        rs1.next();
        rs1.getCharacterStream("S_");
        Clob clob0 = rs1.getClob("CLOB3_0_0_");
        rs1.wasNull();
        rs1.next();
        rs1.close();
        prep2.getMaxRows();
        prep2.getQueryTimeout();
        prep2.close();
        conn0.getAutoCommit();
        Reader r = clob0.getCharacterStream();
        for (int i = 0; i < 10000; i++) {
            int ch = r.read();
            if (ch != ('0' + (i % 10))) {
                fail("expected " + (char) ('0' + (i % 10)) + " got: " + ch + " (" + (char) ch + ")");
            }
View Full Code Here

Examples of java.sql.Clob

        conn = reconnect(conn);
        ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST ORDER BY ID");
        while (rs.next()) {
            int i = rs.getInt("ID");
            Blob b = rs.getBlob("B");
            Clob c = rs.getClob("C");
            int l = i;
            assertEquals(l, b.length());
            assertEquals(l, c.length());
            assertEqualStreams(getRandomStream(l, i), b.getBinaryStream(), -1);
            assertEqualReaders(getRandomReader(l, i), c.getCharacterStream(), -1);
        }

        prep = conn.prepareStatement("UPDATE TEST SET B=?, C=? WHERE ID=?");
        for (int i = first; i < len; i += increment) {
            int l = i;
            prep.setBinaryStream(1, getRandomStream(l, -i), -1);
            prep.setCharacterStream(2, getRandomReader(l, -i), -1);
            prep.setInt(3, i);
            prep.execute();
        }

        conn = reconnect(conn);
        rs = conn.createStatement().executeQuery("SELECT * FROM TEST ORDER BY ID");
        while (rs.next()) {
            int i = rs.getInt("ID");
            Blob b = rs.getBlob("B");
            Clob c = rs.getClob("C");
            int l = i;
            assertEquals(l, b.length());
            assertEquals(l, c.length());
            assertEqualStreams(getRandomStream(l, -i), b.getBinaryStream(), -1);
            assertEqualReaders(getRandomReader(l, -i), c.getCharacterStream(), -1);
        }

        conn.close();
    }
View Full Code Here

Examples of java.sql.Clob

        assertEqualReaders(new CharArrayReader("Bohlen".toCharArray()), rs.getCharacterStream("C"), -1);
        rs.next();
        assertEqualReaders(new CharArrayReader("B\u00f6hlen".toCharArray()), rs.getCharacterStream("C"), -1);
        rs.next();
        assertEqualReaders(getRandomReader(501, 1), rs.getCharacterStream("C"), -1);
        Clob clob = rs.getClob("C");
        assertEqualReaders(getRandomReader(501, 1), clob.getCharacterStream(), -1);
        assertEquals(501, clob.length());
        rs.next();
        assertEqualReaders(getRandomReader(401, 2), rs.getCharacterStream("C"), -1);
        assertEqualReaders(getRandomReader(1500, 2), rs.getCharacterStream("C"), 401);
        clob = rs.getClob("C");
        assertEqualReaders(getRandomReader(1501, 2), clob.getCharacterStream(), 401);
        assertEqualReaders(getRandomReader(401, 2), clob.getCharacterStream(), 401);
        assertEquals(401, clob.length());
        assertFalse(rs.next());
        conn.close();
    }
View Full Code Here

Examples of java.sql.Clob

            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();
        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);
        rs.next();
        c2 = rs.getClob(2);
        assertEquals(length, c2.length());
        s2 = c2.getSubString(1, length);
        assertEquals(s, s2);
    }
View Full Code Here

Examples of java.sql.Clob

import junit.framework.TestCase;

public class TestDataTypeTransformer extends TestCase {
 
  public void testClobToStringConversion() throws Exception {
    Clob clob = new SerialClob("foo".toCharArray()); //$NON-NLS-1$
    String value = DataTypeTransformer.getString(clob);
    assertEquals("foo", value); //$NON-NLS-1$
  }
View Full Code Here

Examples of java.sql.Clob

       
        String result = null;
        if (object instanceof Blob || object instanceof Clob || object instanceof SQLXML) {
         
          if (object instanceof Clob){
            Clob c = (Clob)object;
            try {
              result = ObjectConverterUtil.convertToString(c.getAsciiStream());
         
        } catch (Throwable e) {
          // TODO Auto-generated catch block
          throw new SQLException(e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.