Java Code Examples for java.sql.Blob.truncate()

The following are Jave code examples for showing how to use truncate() of the java.sql.Blob class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: the-vigilantes   File: BlobRegressionTest.java   View Source Code Vote up 5 votes
public void testBug34677() throws Exception {
    createTable("testBug34677", "(field1 BLOB)");
    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());

}
 
Example 2
Project: OpenVertretung   File: BlobRegressionTest.java   View Source Code Vote up 5 votes
public void testBug34677() throws Exception {
    createTable("testBug34677", "(field1 BLOB)");
    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());

}
 
Example 3
Project: ProyectoPacientes   File: BlobRegressionTest.java   View Source Code Vote up 5 votes
public void testBug34677() throws Exception {
    createTable("testBug34677", "(field1 BLOB)");
    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());

}
 
Example 4
Project: BibliotecaPS   File: BlobRegressionTest.java   View Source Code Vote up 5 votes
public void testBug34677() throws Exception {
    createTable("testBug34677", "(field1 BLOB)");
    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());

}
 
Example 5
Project: ipf-flow-manager   File: HibernateUtils.java   View Source Code Vote up 3 votes
/**
 * Writes a byte array to a {@link Blob}.
 * 
 * @param bytes
 *            byte array.
 * @param blob
 *            an initialized {@link Blob}.
 * @return the {@link Blob} instance passed as <code>blob</code> argument.
 * @throws SQLException
 */
public static Blob writeToBlob(byte[] bytes, Blob blob, Session session) throws SQLException {
    if (/*blob != null*/ false) { // not supported
        blob.setBytes(0, bytes);
        blob.truncate(bytes.length);
    } else {
        blob = Hibernate.getLobCreator(session).createBlob(bytes);
    }
    return blob;
}