`

result set type is 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();

 
分享到:
评论

相关推荐

    php.ini-development

    directive because it is not set or is mistyped, a default value will be used. ; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one ; of the INI constants (On, Off, True, ...

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

    Another type of table lock is a schema stability lock (Sch-S) and is compatible with all table locks except the schema modification lock (Sch-M). The schema modification lock (Sch-M) is incompatible ...

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

    One exception is if Foo is used in myfile.cc, it's ok to #include (or forward-declare) Foo in myfile.h, instead of myfile.cc. Inline Functions link ▶Define functions inline only when they are ...

    Using LUA with Visual C++ (Introduction)

    The fourth parameter (errfunc) is only valid for the lua_pcall function and is used for controlling the error-handling. Please read the LUA manual for more information about this parameter. A note ...

    数据库工具类DatabaseUtil.java

    * these objects must have a method signature is void close(). * * @param resource - * jdbc resouce to close */ public void closeJDBCResource(Object resource) { try { Class<? extends Object> ...

    8-07-14_MegaCLI for linux_windows

    SCGCQ00452383 (CSET) - New version MegaCli did not show iBBU06 over temperature as old when temperature is high SCGCQ00454980 (CSET) - storcli /c0 show is not listinf SWR controller SCGCQ00459022 ...

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

    Java邮件开发Fundamentals of the JavaMail API

    doesn't sound like much, but it is your basic MIME-type support found in many browsers and mail tools today. After downloading the framework, unbundle the jaf1_0_1.zip file, and add the activation....

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

    acpi控制笔记本风扇转速

    is larger than the largest known FADT version, and 2) if there is a mismatch between a 32-bit block address and the 64-bit X counterpart (when both are non-zero.) Example Code and Data Size: These ...

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

    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(); ...

    计算机网络第六版答案

    From Wikipedia: Diplomatic protocol is commonly described as a set of international courtesy rules. These well-established and time-honored rules have made it easier for nations and people to live ...

    通信原理英文版教学课件: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

    <br>Adding support for a new toolchain is straightforward. Use the sample projects or the Helix makefiles as a template for which source files to include. <br>Multichannel For multichannel,...

    occam一维反演

    c runocc is the calling program for OCCAM v2.0. C C REFERENCES: CONSTABLE, PARKER & CONSTABLE, 1987: GEOPHYSICS 52, 289-300. C DEGROOT-HEDLIN & CONSTABLE, 1990: GEOPHYSICS 55, 1613-1624. C CONSTABLE,...

    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