Package java.sql

Examples of java.sql.Blob.truncate()


        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

          try
          {
            Assert.assertTrue(results.next());
            blob = results.getBlob(1);
            expected = "1234";
            blob.truncate(blob.length());
           
            /* Not supported by HSQLDB
            writer = new OutputStreamWriter(blob.setBinaryStream(1));
            writer.write(expected);
            writer.close();
View Full Code Here

          try
          {
            Assert.assertTrue(results.next());
            blob = results.getBlob(1);
            expected = "1234";
            blob.truncate(blob.length());
           
            /* Not supported by HSQLDB
            writer = new OutputStreamWriter(blob.setBinaryStream(1));
            writer.write(expected);
            writer.close();
View Full Code Here

                throw new IOException("Failed select blob for message: " + messageID + " 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 {
View Full Code Here

    this.stmt.executeUpdate("INSERT INTO testBug34677 VALUES ('abc')");

    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());

  }
}
View Full Code Here

                     new ByteArrayInputStream(bytes));

        // Truncate the BLOB. This used to fail with "Reached EOF prematurely"
        // because truncate() didn't move the position in the underlying stream
        // back to the beginning.
        blob.truncate(4000);

        // Verify that the BLOB was truncated correctly.
        assertEquals(4000, blob.length());
        bytes = blob.getBytes(1, 4000);
        assertEquals(new LoopingAlphabetStream(4000),
View Full Code Here

    this.stmt.executeUpdate("INSERT INTO testBug34677 VALUES ('abc')");

    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());

  }
}
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

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.