⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e269. moving the cursor in a scrollable result set.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
This example demonstrates the various methods for moving the cursor in a scrollable result set. 
    try {
        // Create a scrollable result set
        Statement stmt = connection.createStatement(
            ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");
    
        // Move cursor forward
        while (resultSet.next()) {
            // Get data at cursor
            String s = resultSet.getString(1);
        }
    
        // Move cursor backward
        while (resultSet.previous()) {
            // Get data at cursor
            String s = resultSet.getString(1);
        }
    
        // Move cursor to the first row
        resultSet.first();
    
        // Move cursor to the last row
        resultSet.last();
    
        // Move cursor to the end, after the last row
        resultSet.afterLast();
    
        // Move cursor to the beginning, before the first row.
        // cursor position is 0.
        resultSet.beforeFirst();
    
        // Move cursor to the second row
        resultSet.absolute(2);
    
        // Move cursor to the last row
        resultSet.absolute(-1);
    
        // Move cursor to the second last row
        resultSet.absolute(-2);
    
        // Move cursor down 5 rows from the current row.  If this moves
        // cursor beyond the last row, cursor is put after the last row
        resultSet.relative(5);
    
        // Move cursor up 3 rows from the current row.  If this moves
        // cursor beyond the first row, cursor is put before the first row
        resultSet.relative(-3);
    } catch (SQLException e) {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -