Java Code Examples for java.sql.ResultSet.absolute()

The following are Jave code examples for showing how to use absolute() of the java.sql.ResultSet 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: BaseTestCase.java   View Source Code Vote up 6 votes
protected void assertResultSetLength(ResultSet rset, int len) throws Exception {
    int oldRowPos = rset.getRow();
    rset.last();
    assertEquals("Result set length", len, rset.getRow());
    if (oldRowPos > 0) {
        rset.absolute(oldRowPos);
    } else {
        rset.beforeFirst();
    }
}
 
Example 2
Project: OpenVertretung   File: BaseTestCase.java   View Source Code Vote up 6 votes
protected void assertResultSetLength(ResultSet rset, int len) throws Exception {
    int oldRowPos = rset.getRow();
    rset.last();
    assertEquals("Result set length", len, rset.getRow());
    if (oldRowPos > 0) {
        rset.absolute(oldRowPos);
    } else {
        rset.beforeFirst();
    }
}
 
Example 3
Project: lams   File: Loader.java   View Source Code Vote up 6 votes
/**
 * Advance the cursor to the first required row of the <tt>ResultSet</tt>
 */
private void advance(final ResultSet rs, final RowSelection selection)
		throws SQLException {

	final int firstRow = LimitHelper.getFirstRow( selection );
	if ( firstRow != 0 ) {
		if ( getFactory().getSettings().isScrollableResultSetsEnabled() ) {
			// we can go straight to the first required row
			rs.absolute( firstRow );
		}
		else {
			// we need to step through the rows one row at a time (slow)
			for ( int m = 0; m < firstRow; m++ ) rs.next();
		}
	}
}
 
Example 4
Project: lams   File: AbstractLoadPlanBasedLoader.java   View Source Code Vote up 6 votes
/**
 * Advance the cursor to the first required row of the <tt>ResultSet</tt>
 */
protected void advance(final ResultSet rs, final RowSelection selection) throws SQLException {
	final int firstRow = LimitHelper.getFirstRow( selection );
	if ( firstRow != 0 ) {
		if ( getFactory().getSettings().isScrollableResultSetsEnabled() ) {
			// we can go straight to the first required row
			rs.absolute( firstRow );
		}
		else {
			// we need to step through the rows one row at a time (slow)
			for ( int m = 0; m < firstRow; m++ ) {
				rs.next();
			}
		}
	}
}
 
Example 5
Project: ProyectoPacientes   File: BaseTestCase.java   View Source Code Vote up 6 votes
protected void assertResultSetLength(ResultSet rset, int len) throws Exception {
    int oldRowPos = rset.getRow();
    rset.last();
    assertEquals("Result set length", len, rset.getRow());
    if (oldRowPos > 0) {
        rset.absolute(oldRowPos);
    } else {
        rset.beforeFirst();
    }
}
 
Example 6
Project: parabuild-ci   File: Loader.java   View Source Code Vote up 6 votes
/**
 * Advance the cursor to the first required row of the <tt>ResultSet</tt>
 */
private void advance(
	final ResultSet rs, 
	final RowSelection selection, 
	final SessionImplementor session) 
throws SQLException {
	
	int firstRow = getFirstRow(selection);
	if ( firstRow!=0 ) {
		if ( session.getFactory().isScrollableResultSetsEnabled() ) {
			// we can go straight to the first required row
			rs.absolute(firstRow);
		}
		else {
			// we need to step through the rows one row at a time (slow)
			for ( int m=0; m<firstRow; m++ ) rs.next();
		}
	}
}
 
Example 7
Project: AeroStory   File: MaplePacketCreator.java   View Source Code Vote up 6 votes
public static byte[] BBSThreadList(ResultSet rs, int start) throws SQLException {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.GUILD_BBS_PACKET.getValue());
    mplew.write(0x06);
    if (!rs.last()) {
        mplew.write(0);
        mplew.writeInt(0);
        mplew.writeInt(0);
        return mplew.getPacket();
    }
    int threadCount = rs.getRow();
    if (rs.getInt("localthreadid") == 0) { //has a notice
        mplew.write(1);
        addThread(mplew, rs);
        threadCount--; //one thread didn't count (because it's a notice)
    } else {
        mplew.write(0);
    }
    if (!rs.absolute(start + 1)) { //seek to the thread before where we start
        rs.first(); //uh, we're trying to start at a place past possible
        start = 0;
    }
    mplew.writeInt(threadCount);
    mplew.writeInt(Math.min(10, threadCount - start));
    for (int i = 0; i < Math.min(10, threadCount - start); i++) {
        addThread(mplew, rs);
        rs.next();
    }
    return mplew.getPacket();
}
 
Example 8
Project: BibliotecaPS   File: BaseTestCase.java   View Source Code Vote up 5 votes
protected void assertResultSetLength(ResultSet rset, int len) throws Exception {
    int oldRowPos = rset.getRow();
    rset.last();
    assertEquals("Result set length", len, rset.getRow());
    if (oldRowPos > 0) {
        rset.absolute(oldRowPos);
    } else {
        rset.beforeFirst();
    }
}
 
Example 9
Project: dev-courses   File: TestUpdatableResults.java   View Source Code Vote up 4 votes
public void testQuery() {

        try {
            Connection c = newConnection();
            Statement st = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                             ResultSet.CONCUR_UPDATABLE);
            String s =
                "CREATE TABLE T (I INTEGER, C CHARACTER(10), B BIT(4) DEFAULT B'')";

            st.execute(s);

            s = "INSERT INTO T VALUES(?,?, DEFAULT)";

            PreparedStatement ps = c.prepareStatement(s);

            for (int i = 1; i <= 20; i++) {
                ps.setInt(1, i);
                ps.setString(2, "TEST " + i);
                ps.execute();
            }

            c.setAutoCommit(false);

            s = "SELECT * FROM T";

            ResultSet rs = st.executeQuery(s);

            rs.absolute(10);
            rs.updateString(2, "UPDATE10");
            rs.updateRow();
            rs.absolute(11);
            rs.deleteRow();
            rs.moveToInsertRow();
            rs.updateInt(1, 1011);
            rs.updateString(2, "INSERT1011");
            rs.updateString(3, "0101");
            rs.insertRow();
            rs.close();

            rs = st.executeQuery(s);

            while (rs.next()) {
                System.out.println("" + rs.getInt(1) + "      "
                                   + rs.getString(2) + "      "
                                   + rs.getString(3));
            }

            st.execute("SHUTDOWN");

            if (!isNetwork) {
                c.close();
            }
        } catch (Exception e) {
            System.out.print(e);
        }
    }