updateBinaryStream ( )源码实例Demo

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

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

源代码1 项目: gemfirexd-oss   文件: BLOBTest.java
/**
 * Tests updating the Blob using result set update methods.
 * @param rs result set, currently positioned on row to be updated
 * @param newVal new value in val column and blob data
 * @param newSize new size of Blob
 * @exception SQLException causes test to fail with error
 * @exception IOException causes test to fail with error
 */
private void testUpdateBlobWithResultSetMethods(final ResultSet rs,
                                                final int newVal,
                                                final int newSize) 
    throws SQLException, IOException
{
    int val = rs.getInt("VAL");
    int size = rs.getInt("LENGTH");
    println("VerifyBlob");
    verifyBlob(val, size, rs.getBlob("DATA"));
    
    println("UpdateBlob");
    final TestInputStream newStream = new TestInputStream(newSize, newVal);
    
    rs.updateInt("VAL", newVal);
    rs.updateInt("LENGTH", newSize);
    rs.updateBinaryStream("DATA", newStream, newSize);
    rs.updateRow();
    
    println("Verify updated blob with another query");
    verifyNewValueInTable(newVal, newSize);
}
 
源代码2 项目: spliceengine   文件: ResultSetTest.java
/**
 * Test <code>updateBinaryStream</code> on a BINARY column, without
 * specifying length of inputstream.
 */
public void testUpdateBinaryStreamLengthless()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

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

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

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码3 项目: spliceengine   文件: ResultSetTest.java
/**
 * Test <code>updateBinaryStream</code> on a BLOB column, without
 * specifying length of inputstream.
 */
public void testUpdateBinaryStreamLengthlessBlob()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    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.updateBinaryStream(1, is2);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码4 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * Test <code>updateBinaryStream</code> on a BLOB column, without
 * specifying length of inputstream.
 */
public void testUpdateBinaryStreamLengthlessBlob()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    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.updateBinaryStream(1, is2);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码5 项目: iaf   文件: WebSphereMsSqlServerDbmsSupport.java
public void updateBlob(ResultSet rs, String column, Object blobUpdateHandle) throws SQLException, JdbcException {
	File blobFile = (File)blobUpdateHandle;
	try {
		InputStream is = new FileInputStream(blobFile); 
		rs.updateBinaryStream(column, is, (int)blobFile.length());
	} catch (FileNotFoundException e) {
		throw new JdbcException("cannot read blob for column ["+column+"] from file ["+blobFile.toString()+"]",e);
	}
}
 
源代码6 项目: iaf   文件: WebSphereMsSqlServerDbmsSupport.java
public void updateBlob(ResultSet rs, int column, Object blobUpdateHandle) throws SQLException, JdbcException {
	File blobFile = (File)blobUpdateHandle;
	try {
		InputStream is = new FileInputStream(blobFile); 
		rs.updateBinaryStream(column, is, (int)blobFile.length());
	} catch (FileNotFoundException e) {
		throw new JdbcException("cannot read blob for column ["+column+"] from file ["+blobFile.toString()+"]",e);
	}
}
 
源代码7 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * Test <code>updateBinaryStream</code> on a BLOB column, without
 * specifying length of inputstream.
 */
public void testUpdateBinaryStreamLengthlessBlob()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    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.updateBinaryStream(1, is2);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dBlob", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码8 项目: gemfirexd-oss   文件: ResultSetTest.java
public void testUpdateBinaryStreamLengthlessParameterName()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

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

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

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码9 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * Test <code>updateBinaryStream</code> on a BINARY column, without
 * specifying length of inputstream.
 */
public void testUpdateBinaryStreamLengthless()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

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

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

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码10 项目: gemfirexd-oss   文件: ResultSetTest.java
public void testUpdateBinaryStreamLengthlessParameterName()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

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

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

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
源代码11 项目: spliceengine   文件: ResultSetTest.java
public void testUpdateBinaryStreamLengthlessParameterName()
        throws IOException, SQLException {
    InputStream is1 = new java.io.ByteArrayInputStream(BYTES1);
    // InputStream used for update.
    InputStream is2 = new java.io.ByteArrayInputStream(BYTES2);

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

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

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    assertEquals(new ByteArrayInputStream(BYTES2), rs1.getBinaryStream(1));
    rs1.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBinaryStreamForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBinaryStream(1, System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBinaryStreamForColumnIndexWithIntegerLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBinaryStream(1, System.in, 1);
    }
}
 
源代码14 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateBinaryStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateBinaryStream()
throws Exception {
    //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];

    //Input Stream inserted initially
    InputStream is = new java.io.ByteArrayInputStream(BYTES1);

    //InputStream that is used for update
    InputStream is_for_update = new
            java.io.ByteArrayInputStream(BYTES2);

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

    //Update operation
    //use a different ResultSet variable so that the
    //other tests can go on unimpacted

    ResultSet rs1 = fetchUpd("dLongBit", key);
    rs1.next();
    rs1.updateBinaryStream(1,is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    InputStream is_ret = rs1.getBinaryStream(1);

    is_ret.read(bytes_ret);
    is_ret.close();

    for(int i=0;i<BYTES2.length;i++) {
        assertEquals("Error in updateBinaryStream",BYTES2[i],bytes_ret[i]);
    }
    rs1.close();
}
 
源代码15 项目: spliceengine   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateBinaryStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateBinaryStreamStringParameterName()
throws Exception {
    //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];

    //Input Stream inserted initially
    InputStream is = new java.io.ByteArrayInputStream(BYTES1);

    //InputStream that is used for update
    InputStream is_for_update = new
            java.io.ByteArrayInputStream(BYTES2);

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

    //Update operation
    //Update operation
    //use a different ResultSet variable so that the
    //other tests can go on unimpacted

    ResultSet rs1 = fetchUpd("dLongBit", key);
    rs1.next();
    rs1.updateBinaryStream("dLongBit",is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dLongBit", key);
    rs1.next();
    InputStream is_ret = rs1.getBinaryStream(1);

    is_ret.read(bytes_ret);
    is_ret.close();

    for(int i=0;i<BYTES2.length;i++) {
        assertEquals("Error in updateBinaryStream",BYTES2[i],bytes_ret[i]);
    }
    rs1.close();
}
 
源代码16 项目: gemfirexd-oss   文件: BlobTest.java
/** Test for bug #42711 from derby's ResultSetTest. */
public void SW_testUpdateBinaryStream() throws Exception {
  setupConnection();
  final Statement stmt = getStatement();
  stmt.execute("create table UpdateTestTableResultSet ("
      + "sno int not null unique," + "dBlob BLOB," + "dClob CLOB,"
      + "dLongVarchar LONG VARCHAR," + "dLongBit LONG VARCHAR FOR BIT DATA)"+ getSuffix());

  // 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];

  // Input Stream inserted initially
  InputStream is = new java.io.ByteArrayInputStream(BYTES1);

  // InputStream that is used for update
  InputStream is_for_update = new java.io.ByteArrayInputStream(BYTES2);

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

  // Update operation
  // use a different ResultSet variable so that the
  // other tests can go on unimpacted

  ResultSet rs1 = fetchUpd("dLongBit", key);
  rs1.next();
  rs1.updateBinaryStream(1, is_for_update, BYTES2.length);
  rs1.updateRow();
  rs1.close();

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

  rs1 = fetch("dLongBit", key);
  rs1.next();
  InputStream is_ret = rs1.getBinaryStream(1);

  is_ret.read(bytes_ret);
  is_ret.close();

  for (int i = 0; i < BYTES2.length; i++) {
    assertEquals("Error in updateBinaryStream", BYTES2[i], bytes_ret[i]);
  }
  rs1.close();

  stmt.execute("drop table UpdateTestTableResultSet");
  this.waitTillAllClear();
  stmt.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBinaryStreamForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBinaryStream("label", System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBinaryStreamForColumnLabelWithIntegerLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBinaryStream("label", System.in, 1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateBinaryStreamForColumnIndexWithLongLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateBinaryStream(1, System.in, 1L);
    }
}
 
源代码20 项目: spotbugs   文件: BadResultSetAccessTest.java
@NoWarning("SQL")
public void test4(ResultSet rs) throws SQLException {
    rs.updateBinaryStream(1, null, 0);
}