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

📄 e270. getting the cursor position in a scrollable result set.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
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");
    
        // Get cursor position
        int pos = resultSet.getRow();            // 0
        boolean b = resultSet.isBeforeFirst();   // true
    
        // Move cursor to the first row
        resultSet.next();
    
        // Get cursor position
        pos = resultSet.getRow();                // 1
        b = resultSet.isFirst();                 // true
    
        // Move cursor to the last row
        resultSet.last();
    
        // Get cursor position
        pos = resultSet.getRow();                // If table has 10 rows, value would be 10
        b = resultSet.isLast();                  // true
    
        // Move cursor past last row
        resultSet.afterLast();
    
        // Get cursor position
        pos = resultSet.getRow();                // If table has 10 rows, value would be 11
        b = resultSet.isAfterLast();             // true
    } catch (SQLException e) {
    }

⌨️ 快捷键说明

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