Package java.sql

Examples of java.sql.Blob.truncate()


            assertEquals (data1 [i], data2 [i]);
        data2 = blob.getBytes (5 * BUFFER_SIZE + 1, UPDATE_SIZE);
        for (int i = 0; i < UPDATE_SIZE; i++)
            assertEquals (data1 [i], data2 [i]);
        //test truncate
        blob.truncate (BUFFER_SIZE);
        assertEquals ("truncate failed", BUFFER_SIZE, blob.length());
        rs.close();
        con.commit();
        stmt.close();
        pstmt.close();
View Full Code Here


        for (int i = 0; i < 100; i++) {
            data [i] = (byte) i;
        }
        blob.setBytes (1, data);
        assertEquals (blob.length(), 100);
        blob.truncate (50);
        assertEquals (blob.length(), 50);
        blob.setBytes (1, data);
        assertEquals ("set failed", blob.length(), 100);
        blob.truncate (50);
        assertEquals ("truncation failed", blob.length(), 50);
View Full Code Here

        assertEquals (blob.length(), 100);
        blob.truncate (50);
        assertEquals (blob.length(), 50);
        blob.setBytes (1, data);
        assertEquals ("set failed", blob.length(), 100);
        blob.truncate (50);
        assertEquals ("truncation failed", blob.length(), 50);
        rs.close();
        con.commit();
        stmt.close();
        pstmt.close();
View Full Code Here

        assertTrue(rs.next());
        Blob blob = rs.getBlob("DATA");

        assertEquals(100, blob.length());

        blob.truncate(50);
        assertEquals(50, blob.length());

        blob.truncate(150);
        assertEquals(150, blob.length());
View Full Code Here

        assertEquals(100, blob.length());

        blob.truncate(50);
        assertEquals(50, blob.length());

        blob.truncate(150);
        assertEquals(150, blob.length());

        data = blob.getBytes(1, 200);
        assertEquals(150, data.length);
        for (byte i=0; i<50; i++) {
View Full Code Here

        rs.next();
        Blob blob = rs.getBlob (1);
        InputStream is = blob.getBinaryStream();
        long l = is.skip (20);
        //truncate blob after accessing original stream
        blob.truncate (l);
        int ret = is.read();
        //should not be able to read after truncated value
        assertEquals ("stream update failed", -1, ret);
        byte [] buffer = new byte [1024];
        for (int i = 0; i < buffer.length; i++)
View Full Code Here

      ReadStream readStream = file.openRead();

      if (_lob instanceof Blob) {
        Blob blob = (Blob) _lob;
        blob.truncate(0);

        if (_outputStream != null)
          _outputStream.close();

        _outputStream = blob.setBinaryStream(0);
View Full Code Here

      case OracleModule.OCI_D_FILE:
        break;
      case OracleModule.OCI_D_LOB:
        if (_lob instanceof Blob) {
          Blob blob = (Blob) _lob;
          blob.truncate(length);
        } else if (_lob instanceof Clob) {
          Clob clob = (Clob) _lob;
          clob.truncate(length);
        }
        break;
View Full Code Here

   
    try {
      this.rs = this.stmt.executeQuery("SELECT field1 FROM testBug34677");
      this.rs.next();
      Blob blob = this.rs.getBlob(1);
      blob.truncate(0L);
      assertEquals(0, blob.length());
      assertEquals(-1, blob.getBinaryStream().read());
    } finally {
      closeMemberJDBCResources();
    }
View Full Code Here

                throw new IOException("Failed select blob for message: " + sequence + " in container.");
            }

            // Update the blob
            Blob blob = rs.getBlob(1);
            blob.truncate(0);
            blob.setBytes(1, data);
            rs.updateBlob(1, blob);
            rs.updateRow();             // Update the row with the updated blob
        } finally {
            close(rs);
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.