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

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

源代码1 项目: gemfirexd-oss   文件: ResultSetTest.java
public void testUpdateAsciiStreamLengthless()
        throws IOException, SQLException {
    // Array to keep updated data fetched from the database.
    byte[] bytesRet = new byte[10];

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

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

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

    // Update the data.
    ResultSet rs1 = fetchUpd("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream(1, isForUpdate);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream isRet = rs1.getAsciiStream(1);
    isRet.read(bytesRet);
    isRet.close();

    for (int i=0; i < BYTES2.length; i++) {
        assertEquals("Error in updateAsciiStream", BYTES2[i], bytesRet[i]);
    }
    rs1.close();
}
 
源代码2 项目: spliceengine   文件: ResultSetTest.java
public void testUpdateAsciiStreamLengthless()
        throws IOException, SQLException {
    // Array to keep updated data fetched from the database.
    byte[] bytesRet = new byte[10];

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

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

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

    // Update the data.
    ResultSet rs1 = fetchUpd("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream(1, isForUpdate);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream isRet = rs1.getAsciiStream(1);
    isRet.read(bytesRet);
    isRet.close();

    for (int i=0; i < BYTES2.length; i++) {
        assertEquals("Error in updateAsciiStream", BYTES2[i], bytesRet[i]);
    }
    rs1.close();
}
 
源代码3 项目: gemfirexd-oss   文件: ResultSetTest.java
public void testUpdateAsciiStreamLengthless()
        throws IOException, SQLException {
    // Array to keep updated data fetched from the database.
    byte[] bytesRet = new byte[10];

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

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

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

    // Update the data.
    ResultSet rs1 = fetchUpd("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream(1, isForUpdate);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream isRet = rs1.getAsciiStream(1);
    isRet.read(bytesRet);
    isRet.close();

    for (int i=0; i < BYTES2.length; i++) {
        assertEquals("Error in updateAsciiStream", BYTES2[i], bytesRet[i]);
    }
    rs1.close();
}
 
源代码4 项目: spliceengine   文件: ResultSetTest.java
public void testUpdateAsciiStreamLengthlessParameterName()
        throws IOException, SQLException {
    // Array to keep updated data fetched from the database.
    byte[] bytesRet = new byte[10];

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

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

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

    // Update the data.
    ResultSet rs1 = fetchUpd("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream("dLongVarchar", isForUpdate);
    rs1.updateRow();
    rs1.close();

    // Query to see whether the data that has been updated.
    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream isRet = rs1.getAsciiStream(1);
    isRet.read(bytesRet);
    isRet.close();

    for (int i=0; i < BYTES2.length; i++) {
        assertEquals("Error in updateAsciiStream", BYTES2[i], bytesRet[i]);
    }
    rs1.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream(1, System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream("label", System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnIndexWithIntegerLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream(1, System.in, 1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnLabelWithIntegerLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream("label", System.in, 1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnIndexWithLongLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream(1, System.in, 1L);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnLabelWithLongLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream("label", System.in, 1L);
    }
}
 
源代码11 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateAsciiStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateAsciiStream()
throws Exception {
    //create the table
    stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
            "datacol LONG VARCHAR)");

    //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 = prepareStatement
            ("insert into UpdateTestTable_ResultSet values(?,?)");
    ps_sb.setInt(1,1);
    ps_sb.setAsciiStream(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 = stmt.executeQuery
            ("select * from UpdateTestTable_ResultSet for update");
    rs1.next();
    rs1.updateAsciiStream(2,is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = stmt.executeQuery
            ("select * from UpdateTestTable_ResultSet");
    rs1.next();
    InputStream is_ret = rs1.getAsciiStream(2);

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

    for(int i=0;i<BYTES2.length;i++) {
        assertEquals("Error in updateAsciiStream",BYTES2[i],bytes_ret[i]);
    }
    rs1.close();
    //delete the table
    stmt .execute("drop table UpdateTestTable_ResultSet");
}
 
源代码12 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateAsciiStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateAsciiStreamStringParameterName()
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("dLongVarchar");
    ps_sb.setInt(1, key);
    ps_sb.setAsciiStream(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("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream("dLongVarchar",is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream is_ret = rs1.getAsciiStream(1);

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

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

public void testUpdateAsciiStreamStringParameterName()
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("dLongVarchar");
    ps_sb.setInt(1, key);
    ps_sb.setAsciiStream(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("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream("dLongVarchar",is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream is_ret = rs1.getAsciiStream(1);

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

    for(int i=0;i<BYTES2.length;i++) {
        assertEquals("Error in updateAsciiStream",BYTES2[i],bytes_ret[i]);
    }
    rs1.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream(1, System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream("label", System.in);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnIndexWithIntegerLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream(1, System.in, 1);
    }
}
 
源代码17 项目: spliceengine   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateAsciiStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateAsciiStream()
throws Exception {
    //create the table
    stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
            "datacol LONG VARCHAR)");

    //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 = prepareStatement
            ("insert into UpdateTestTable_ResultSet values(?,?)");
    ps_sb.setInt(1,1);
    ps_sb.setAsciiStream(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 = stmt.executeQuery
            ("select * from UpdateTestTable_ResultSet for update");
    rs1.next();
    rs1.updateAsciiStream(2,is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = stmt.executeQuery
            ("select * from UpdateTestTable_ResultSet");
    rs1.next();
    InputStream is_ret = rs1.getAsciiStream(2);

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

    for(int i=0;i<BYTES2.length;i++) {
        assertEquals("Error in updateAsciiStream",BYTES2[i],bytes_ret[i]);
    }
    rs1.close();
    //delete the table
    stmt .execute("drop table UpdateTestTable_ResultSet");
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateAsciiStreamForColumnLabelWithLongLength() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateAsciiStream("label", System.in, 1L);
    }
}
 
源代码19 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateAsciiStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateAsciiStream()
throws Exception {
    //create the table
    stmt.execute("create table UpdateTestTable_ResultSet (sno int, " +
            "datacol LONG VARCHAR)");

    //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 = prepareStatement
            ("insert into UpdateTestTable_ResultSet values(?,?)");
    ps_sb.setInt(1,1);
    ps_sb.setAsciiStream(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 = stmt.executeQuery
            ("select * from UpdateTestTable_ResultSet for update");
    rs1.next();
    rs1.updateAsciiStream(2,is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = stmt.executeQuery
            ("select * from UpdateTestTable_ResultSet");
    rs1.next();
    InputStream is_ret = rs1.getAsciiStream(2);

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

    for(int i=0;i<BYTES2.length;i++) {
        assertEquals("Error in updateAsciiStream",BYTES2[i],bytes_ret[i]);
    }
    rs1.close();
    //delete the table
    stmt .execute("drop table UpdateTestTable_ResultSet");
}
 
源代码20 项目: gemfirexd-oss   文件: ResultSetTest.java
/**
 * This methods tests the ResultSet interface method
 * updateAsciiStream
 *
 * @throws SQLException if some error occurs while calling the method
 */

public void testUpdateAsciiStreamStringParameterName()
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("dLongVarchar");
    ps_sb.setInt(1, key);
    ps_sb.setAsciiStream(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("dLongVarchar", key);
    rs1.next();
    rs1.updateAsciiStream("dLongVarchar",is_for_update,(int)BYTES2.length);
    rs1.updateRow();
    rs1.close();

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

    rs1 = fetch("dLongVarchar", key);
    rs1.next();
    InputStream is_ret = rs1.getAsciiStream(1);

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

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