`
andy54321
  • 浏览: 441403 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

result属性之type_forward_only

阅读更多

connect=dataSource.getConnection();
Statement stmt=connect.createStatement();
ResultSet rs=stmt.executeQuery(strSql);
rs.last();

这样写之后会报rs.last()有错,后来看到last()方法:

Throws:
SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY

后来查明原因果然是因为the result set type is TYPE_FORWARD_ONLY,查明的具体过程是:System.out.println(rs.getType());看到打印出来的结果是1003,后到JDK的src里面查到int TYPE_FORWARD_ONLY = 1003;这句话,说明the result set type is TYPE_FORWARD_ONLY。

那么解决办法就是要把the result set type 不要设成 TYPE_FORWARD_ONLY,后来在网上查到解决办法是:

connect=dataSource.getConnection();
Statement stmt=connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,  
                    ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(strSql);
rs.last();

--------------------------

resultSet 方法很多,我也是在使用时用到rs.beforeFirst(),报错,才查找到的,看来API还是很有用的

 

分享到:
评论

相关推荐

    分布式数据库UPDRDB介绍.pptx

    流式处理允许数据以字段、行的形式逐个返回,减少了内存消耗,并且支持多种编程接口,如MySQL命令行、C-API的use_result和JAVA的ResultSet.TYPE_FORWARD_ONLY、ResultSet.CONCUR_READ_ONLY等。这种模式优化了数据...

    常用jdbc包和面试题

    ** ResultSet的类型有三种:TYPE_FORWARD_ONLY(默认,只能向前滚动),TYPE_SCROLL_INSENSITIVE(可滚动但不关心数据变化),TYPE_SCROLL_SENSITIVE(可滚动并关心数据变化)。 9. **如何在JDBC中执行批量更新?**...

    我的笔记:Struts构架中action的跳转大全

    <forward name="success" path="/result.jsp"/> ``` 这种方式下,`someForm`表单被多个Action共享。这意味着当用户提交表单时,第一个Action处理请求,并可能将控制权传递给第二个Action,后者继续使用同一个表单...

    php常用ODBC函数集(详细)

    语法为`odbc_connect($dsn, $user, $password, $cursor_type=SQL_CURSOR_FORWARD_ONLY)`,其中$dsn是数据源名,$user和$password分别是数据库登录的用户名和密码,$cursor_type可选,用于指定游标类型。 2. **odbc_...

    Using LUA with Visual C++ (Introduction)

    There are many other stack manipulation functions and there are also functions to verify the value type on the stack. I suggest that you check out the LUA manual that comes with the distribution. ...

    JDBC连接数据库JDBC连接数据库.ppt

    4. **结果集处理优化**:如使用`ResultSet.TYPE_FORWARD_ONLY`和`ResultSet.CONCUR_READ_ONLY`模式,减少内存占用。 5. **异常处理**:正确捕获和处理SQLException,确保程序健壮性。 总的来说,JDBC提供了一套标准...

    数据库工具类DatabaseUtil.java

    * 可滚动的 Statement 不能执行 SELECT MAX(ID) 之类的查询语句(SQLServer 2000) * * @param sql * 需要执行的 SQL * @return 记录总数 */ public int getAllCount(String sql) { try { Statement ...

    php.ini-development

    should be disabled, as enabling it may result in issues when generating XML ; documents, however this remains supported for backward compatibility reasons. ; Note that this directive does not control...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Other C++ Features Reference Arguments Function Overloading Default Arguments Variable-Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and ...

    Oracle EBS R12 Order Management_TRAIN

    - **Credit Only**: RMAs that result in credit being issued to the customer without returning physical goods. - **Receipt and No Credit**: RMAs where goods are returned but no credit is issued. - **...

    8-07-14_MegaCLI for linux_windows

    包含如下操作系统版本 FreeBSD Linux Solaris Windows 分别对应如下目录 MegaCLI for DOS MegaCLI for Linux MegaCLI for Solaris MegaCLI for FreeBSD MegaCLI for Windows ********************************...

    MongoDB查询的JavaScript实现Mingo.zip

    // iteration is forward only while (cursor.hasNext()) {  console.log(cursor.next()); } // use first(), last() and all() to retrieve matched objects cursor.first(); cursor.last(); ...

    Bochs - The cross platform IA-32 (x86) emulator

    devices (currently only used to set the speed reported by device and to specify an alternative redolog file of USB MSD disk image modes) - hard drive - new disk image mode 'vvfat' - ported the ...

    k7 SRIO参考例程

    - CR#467668 / AR#30322 - Modified Logical Layer to properly forward eof through the pipeline. - Some Logical Layer CARs are not being set correctly in the core. - Version fixed : v4.4 - CR#...

    acpi控制笔记本风扇转速

    operand to be an operation region of any type. It is now restricted to regions of type SystemMemory, as per the ACPI specification. BZ 481 Additional cleanup and optimizations for the new Table ...

    微软内部资料-SQL性能优化3

    SQL Server never asks for SIX locks directly, they are always the result of a conversion. For example, suppose a transaction scanned a page using an S lock and then subsequently decided to perform a ...

    Java邮件开发Fundamentals of the JavaMail API

    the JavaMail API, if you want this type of information, you have to calculate it yourself. IMAP IMAP is a more advanced protocol for receiving messages. Defined in RFC 2060 , IMAP stands for ...

    通信原理英文版教学课件:Chapter 10 Channel Coding and Error Control.ppt

    2. **Forward Error Correction (FEC)**: FEC methods go beyond mere error detection by incorporating error control symbols that both discover and correct errors. This eliminates the need for ...

    Heilx AAC Decoder optimized for ARM

    C and assembly code only (C++ not required for codec library) - reentrant, statically linkable - low memory (details in docs/ subdirectory) - option to use Intel Integrated Performance ...

    occam一维反演

    C TYPE AND DIMENSION). OBJMAT IS ALSO RESPONSIBLE FOR SETTING ANY C WEIGHTS, /RESULT/PREWTS(), ASSOCIATED WITH THE MODEL PREJUDICE, ALTHOUGH C THESE DEFAULT TO ZERO IF NOT SET. c DATIME(DATETM), ...

Global site tag (gtag.js) - Google Analytics