Java Code Examples for java.sql.ResultSet#rowDeleted()

The following examples show how to use java.sql.ResultSet#rowDeleted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Delete a random sample of n records in the resultset
 * @param rs result set to be updated
 * @param rows map of rows, will also be updated
 * @param deletedRows set of rows being deleted (position in RS)
 * @param k number of records to be deleted
 */
private void deleteRandomSampleOfNRecords(final ResultSet rs, 
                                          final Map rows,
                                          final Set deletedRows,
                                          final int k) 
    throws SQLException
{
    List sampledKeys = createRandomSample(rows, k);
    println("Sampled keys:" + sampledKeys);
    ResultSetMetaData meta = rs.getMetaData();
    for (Iterator i = sampledKeys.iterator(); i.hasNext();) {
        Integer key = (Integer) i.next();
        rs.absolute(key.intValue());            
        if (rs.rowDeleted()) continue; // skip deleting row if already deleted
        if (positioned) {
            createStatement().executeUpdate
                    ("DELETE FROM T1 WHERE CURRENT OF \"" + cursorName + 
                     "\"");
        } else {
            rs.deleteRow();
        }
        rs.relative(0);
        println("Deleted row " + key);
        // Update the rows table
        rows.put(key, getRowString(rs));
        
        // Update the updatedRows set
        deletedRows.add(key);
    }
}
 
Example 2
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Get a concatenation of the values of the 
 * current Row in the ResultSet
 */
private String getRowString(final ResultSet rs) 
    throws SQLException
{
    int numberOfColumns = rs.getMetaData().getColumnCount();
    StringBuilder sb = new StringBuilder();
    if (rs.rowDeleted()) return "";
    for (int i = 1; i <= numberOfColumns; i++) {
        sb.append(rs.getString(i));
        if (i < numberOfColumns) { 
            sb.append(','); 
        }
    }
    return sb.toString();
}
 
Example 3
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Delete a random sample of n records in the resultset
 * @param rs result set to be updated
 * @param rows map of rows, will also be updated
 * @param deletedRows set of rows being deleted (position in RS)
 * @param k number of records to be deleted
 */
private void deleteRandomSampleOfNRecords(final ResultSet rs, 
                                          final Map rows,
                                          final Set deletedRows,
                                          final int k) 
    throws SQLException
{
    List sampledKeys = createRandomSample(rows, k);
    println("Sampled keys:" + sampledKeys);
    ResultSetMetaData meta = rs.getMetaData();
    for (Iterator i = sampledKeys.iterator(); i.hasNext();) {
        Integer key = (Integer) i.next();
        rs.absolute(key.intValue());            
        if (rs.rowDeleted()) continue; // skip deleting row if already deleted
        if (positioned) {
            createStatement().executeUpdate
                    ("DELETE FROM T1 WHERE CURRENT OF \"" + cursorName + 
                     "\"");
        } else {
            rs.deleteRow();
        }
        rs.relative(0);
        println("Deleted row " + key);
        // Update the rows table
        rows.put(key, getRowString(rs));
        
        // Update the updatedRows set
        deletedRows.add(key);
    }
}
 
Example 4
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Get a concatenation of the values of the 
 * current Row in the ResultSet
 */
private String getRowString(final ResultSet rs) 
    throws SQLException
{
    int numberOfColumns = rs.getMetaData().getColumnCount();
    StringBuilder sb = new StringBuilder();
    if (rs.rowDeleted()) return "";
    for (int i = 1; i <= numberOfColumns; i++) {
        sb.append(rs.getString(i));
        if (i < numberOfColumns) { 
            sb.append(','); 
        }
    }
    return sb.toString();
}
 
Example 5
Source File: SURQueryMixTest.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Delete a random sample of n records in the resultset
 * @param rs result set to be updated
 * @param rows map of rows, will also be updated
 * @param deletedRows set of rows being deleted (position in RS)
 * @param k number of records to be deleted
 */
private void deleteRandomSampleOfNRecords(final ResultSet rs, 
                                          final Map rows,
                                          final Set deletedRows,
                                          final int k) 
    throws SQLException
{
    List sampledKeys = createRandomSample(rows, k);
    println("Sampled keys:" + sampledKeys);
    ResultSetMetaData meta = rs.getMetaData();
    for (Iterator i = sampledKeys.iterator(); i.hasNext();) {
        Integer key = (Integer) i.next();
        rs.absolute(key.intValue());            
        if (rs.rowDeleted()) continue; // skip deleting row if already deleted
        if (positioned) {
            createStatement().executeUpdate
                    ("DELETE FROM T1 WHERE CURRENT OF \"" + cursorName + 
                     "\"");
        } else {
            rs.deleteRow();
        }
        rs.relative(0);
        println("Deleted row " + key);
        // Update the rows table
        rows.put(key, getRowString(rs));
        
        // Update the updatedRows set
        deletedRows.add(key);
    }
}
 
Example 6
Source File: SURQueryMixTest.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Get a concatenation of the values of the 
 * current Row in the ResultSet
 */
private String getRowString(final ResultSet rs) 
    throws SQLException
{
    int numberOfColumns = rs.getMetaData().getColumnCount();
    StringBuffer sb = new StringBuffer();
    if (rs.rowDeleted()) return "";
    for (int i = 1; i <= numberOfColumns; i++) {
        sb.append(rs.getString(i));
        if (i < numberOfColumns) { 
            sb.append(','); 
        }
    }
    return sb.toString();
}
 
Example 7
Source File: UnsupportedOperationResultSetTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertRowDeleted() throws SQLException {
    for (ResultSet each : resultSets) {
        each.rowDeleted();
    }
}
 
Example 8
Source File: UnsupportedOperationResultSetTest.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertRowDeleted() throws SQLException {
    for (ResultSet each : resultSets) {
        each.rowDeleted();
    }
}