`
andy54321
  • 浏览: 436595 次
  • 性别: 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还是很有用的

 

分享到:
评论

相关推荐

    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. ...

    数据库工具类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 ...

    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 ...

    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), ...

    Vagaa哇嘎画时代--体验群体智慧的力量!

    2.8 Disrupt the normal flow of dialogue, cause a screen to "scroll" faster than other users are able to type, or otherwise act in a manner that negatively affects other users' ability to engage in ...

    计算机网络第六版答案

    These solutions are being made available to instructors ONLY. Please do NOT copy or distribute this document to others (even other instructors). Please do not post any solutions on a publicly-...

    The Art of Assembly Language Programming

    You are visitor as of October 17, 1996. The Art of Assembly Language Programming <br>Forward Why Would Anyone Learn This Stuff? 1 What's Wrong With Assembly Language 2 What's Right With ...

Global site tag (gtag.js) - Google Analytics