java.sql.ResultSet#updateBlob ( )源码实例Demo

下面列出了java.sql.ResultSet#updateBlob ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gemfirexd-oss   文件: ResultSetTest.java
public void testUpdateBlobWithStreamLengthlessParameterName()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob("dBlob", is2);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码2 项目: spliceengine   文件: ResultSetTest.java
public void testUpdateBlobLengthless()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob(1, is2);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码3 项目: gemfirexd-oss   文件: ResultSetTest.java
public void testUpdateBlobLengthless()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob(1, is2);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码4 项目: spliceengine   文件: ResultSetTest.java
/**
 * Tests the updateBlob that accepts a input stream and the length of the IS
 * and the parameter name String.
 *
 * @throws an Exception
 */
public void testUpdateBlobStringParameterNameWithLengthofIS()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob("dBlob", is2, BYTES2.length);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码5 项目: spliceengine   文件: ResultSetTest.java
/**
 * tests the updateBlob that accepts a input stream and the length of the IS.
 *
 * @throws an Exception
 */
public void testUpdateBlobWithLengthofIS()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob(1, is2, BYTES2.length);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码6 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * Tests the updateBlob that accepts a input stream and the length of the IS
 * and the parameter name String.
 *
 * @throws an Exception
 */
public void testUpdateBlobStringParameterNameWithLengthofIS()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob("dBlob", is2, BYTES2.length);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码7 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * Tests the updateBlob that accepts a input stream and the length of the IS
 * and the parameter name String.
 *
 * @throws an Exception
 */
public void testUpdateBlobStringParameterNameWithLengthofIS()
        throws Exception {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream for insertion.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    // Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2, is1);
    ps_sb.executeUpdate();
    ps_sb.close();

    // Update operation
    ResultSet rs1 = fetchUpd("dBlob", key);
    rs1.next();
    rs1.updateBlob("dBlob", is2, BYTES2.length);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnIndexWithInputStream() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob(1, System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnLabelWithInputStream() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob("label", System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnIndexWithInputStreamAndLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob(1, System.in, 100);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnLabelWithInputStreamAndLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob("label", System.in, 100);
    }
}
 
源代码12 项目: spliceengine   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateBlob
 *
 * @throws SQLException if some error occurs while calling the method
 */
public void testUpdateBlobStringParameterName()
throws Exception {
    // Life span of Blob objects are limited by the transaction.  Need
    // autocommit off so Blob objects survive execution of next statement.
    getConnection().setAutoCommit(false);

    //Byte array in which the returned bytes from
    //the Database after the update are stored. This
    //array is then checked to determine if it
    //has the same elements of the Byte array used for
    //the update operation

    byte[] bytes_ret = new byte[10];

    //1 Input Stream for insertion
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);

    //2 Input Stream for insertion
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    //Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");

    //first insert
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2,is1,BYTES1.length);
    ps_sb.executeUpdate();

    //second insert
    int key2 = requestKey();
    ps_sb.setInt(1, key2);
    ps_sb.setBinaryStream(2,is2,BYTES2.length);
    ps_sb.executeUpdate();

    ps_sb.close();

    //Update operation
    //use a different ResultSet variable so that the
    //other tests can go on unimpacted
    //we do not have set methods on Clob and Blob implemented
    //So query the first Clob from the database
    //update the second result set with this
    //Clob value

    ResultSet rs1 = fetch("dBlob", key);
    rs1.next();
    Blob blob = rs1.getBlob(1);
    rs1.close();

    rs1 = fetchUpd("dBlob", key2);
    rs1.next();
    rs1.updateBlob("dBlob",blob);
    rs1.updateRow();
    rs1.close();

    //Query to see whether the data that has been updated
    //using the updateBlob method is the same
    //data that we expected

    rs1 = fetch("dBlob", key2);
    rs1.next();
    assertEquals(blob, rs1.getBlob(1)); 
    rs1.close();
}
 
源代码13 项目: iaf   文件: GenericDbmsSupport.java
@Override
public void updateBlob(ResultSet rs, String column, Object blobUpdateHandle) throws SQLException, JdbcException {
	// updateBlob is not implemented by the WebSphere implementation of ResultSet
	rs.updateBlob(column, (Blob)blobUpdateHandle);
}
 
源代码14 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateBlob
 *
 * @throws SQLException if some error occurs while calling the method
 */
public void testUpdateBlobStringParameterName()
throws Exception {
    // Life span of Blob objects are limited by the transaction.  Need
    // autocommit off so Blob objects survive execution of next statement.
    getConnection().setAutoCommit(false);

    //Byte array in which the returned bytes from
    //the Database after the update are stored. This
    //array is then checked to determine if it
    //has the same elements of the Byte array used for
    //the update operation

    byte[] bytes_ret = new byte[10];

    //1 Input Stream for insertion
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);

    //2 Input Stream for insertion
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    //Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");

    //first insert
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2,is1,BYTES1.length);
    ps_sb.executeUpdate();

    //second insert
    int key2 = requestKey();
    ps_sb.setInt(1, key2);
    ps_sb.setBinaryStream(2,is2,BYTES2.length);
    ps_sb.executeUpdate();

    ps_sb.close();

    //Update operation
    //use a different ResultSet variable so that the
    //other tests can go on unimpacted
    //we do not have set methods on Clob and Blob implemented
    //So query the first Clob from the database
    //update the second result set with this
    //Clob value

    ResultSet rs1 = fetch("dBlob", key);
    rs1.next();
    Blob blob = rs1.getBlob(1);
    rs1.close();

    rs1 = fetchUpd("dBlob", key2);
    rs1.next();
    rs1.updateBlob("dBlob",blob);
    rs1.updateRow();
    rs1.close();

    //Query to see whether the data that has been updated
    //using the updateBlob method is the same
    //data that we expected

    rs1 = fetch("dBlob", key2);
    rs1.next();
    assertEquals(blob, rs1.getBlob(1)); 
    rs1.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob("label", (Blob) null);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnIndexWithInputStream() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob(1, System.in);
    }
}
 
源代码17 项目: spliceengine   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateBlob
 *
 * @throws SQLException if some error occurs while calling the method
 */
public void testUpdateBlob()
throws Exception {

    // Life span of Blob objects are limited by the transaction.  Need
    // autocommit off so Blob objects survive execution of next statement.
    getConnection().setAutoCommit(false);

    //Byte array in which the returned bytes from
    //the Database after the update are stored. This
    //array is then checked to determine if it
    //has the same elements of the Byte array used for
    //the update operation

    byte[] bytes_ret = new byte[10];

    //1 Input Stream for insertion
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);

    //2 Input Stream for insertion
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    //Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");

    //first insert
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2,is1,BYTES1.length);
    ps_sb.executeUpdate();

    //second insert
    int key2 = requestKey();
    ps_sb.setInt(1, key2);
    ps_sb.setBinaryStream(2,is2,BYTES2.length);
    ps_sb.executeUpdate();

    ps_sb.close();

    //Update operation
    //use a different ResultSet variable so that the
    //other tests can go on unimpacted
    //we do not have set methods on Clob and Blob implemented
    //So query the first Clob from the database
    //update the second result set with this
    //Clob value

    ResultSet rs1 = fetch("dBlob", key);
    rs1.next();
    Blob blob = rs1.getBlob(1);
    rs1.close();

    rs1 = fetchUpd("dBlob", key2);
    rs1.next();
    rs1.updateBlob(1,blob);
    rs1.updateRow();
    rs1.close();

    //Query to see whether the data that has been updated
    //using the updateBlob method is the same
    //data that we expected

    rs1 = fetch("dBlob", key2);
    rs1.next();
    assertEquals(blob, rs1.getBlob(1));
    rs1.close();
}
 
源代码18 项目: iaf   文件: GenericDbmsSupport.java
@Override
public void updateBlob(ResultSet rs, int column, Object blobUpdateHandle) throws SQLException, JdbcException {
	// updateBlob is not implemented by the WebSphere implementation of ResultSet
	rs.updateBlob(column, (Blob)blobUpdateHandle);
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBlobForColumnLabelWithInputStreamAndLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBlob("label", System.in, 100);
    }
}
 
源代码20 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateBlob
 *
 * @throws SQLException if some error occurs while calling the method
 */
public void testUpdateBlob()
throws Exception {

    // Life span of Blob objects are limited by the transaction.  Need
    // autocommit off so Blob objects survive execution of next statement.
    getConnection().setAutoCommit(false);

    //Byte array in which the returned bytes from
    //the Database after the update are stored. This
    //array is then checked to determine if it
    //has the same elements of the Byte array used for
    //the update operation

    byte[] bytes_ret = new byte[10];

    //1 Input Stream for insertion
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);

    //2 Input Stream for insertion
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

    //Prepared Statement used to insert the data
    PreparedStatement ps_sb = prep("dBlob");

    //first insert
    ps_sb.setInt(1, key);
    ps_sb.setBinaryStream(2,is1,BYTES1.length);
    ps_sb.executeUpdate();

    //second insert
    int key2 = requestKey();
    ps_sb.setInt(1, key2);
    ps_sb.setBinaryStream(2,is2,BYTES2.length);
    ps_sb.executeUpdate();

    ps_sb.close();

    //Update operation
    //use a different ResultSet variable so that the
    //other tests can go on unimpacted
    //we do not have set methods on Clob and Blob implemented
    //So query the first Clob from the database
    //update the second result set with this
    //Clob value

    ResultSet rs1 = fetch("dBlob", key);
    rs1.next();
    Blob blob = rs1.getBlob(1);
    rs1.close();

    rs1 = fetchUpd("dBlob", key2);
    rs1.next();
    rs1.updateBlob(1,blob);
    rs1.updateRow();
    rs1.close();

    //Query to see whether the data that has been updated
    //using the updateBlob method is the same
    //data that we expected

    rs1 = fetch("dBlob", key2);
    rs1.next();
    assertEquals(blob, rs1.getBlob(1));
    rs1.close();
}