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还是很有用的
分享到:
相关推荐
流式处理允许数据以字段、行的形式逐个返回,减少了内存消耗,并且支持多种编程接口,如MySQL命令行、C-API的use_result和JAVA的ResultSet.TYPE_FORWARD_ONLY、ResultSet.CONCUR_READ_ONLY等。这种模式优化了数据...
** ResultSet的类型有三种:TYPE_FORWARD_ONLY(默认,只能向前滚动),TYPE_SCROLL_INSENSITIVE(可滚动但不关心数据变化),TYPE_SCROLL_SENSITIVE(可滚动并关心数据变化)。 9. **如何在JDBC中执行批量更新?**...
<forward name="success" path="/result.jsp"/> ``` 这种方式下,`someForm`表单被多个Action共享。这意味着当用户提交表单时,第一个Action处理请求,并可能将控制权传递给第二个Action,后者继续使用同一个表单...
语法为`odbc_connect($dsn, $user, $password, $cursor_type=SQL_CURSOR_FORWARD_ONLY)`,其中$dsn是数据源名,$user和$password分别是数据库登录的用户名和密码,$cursor_type可选,用于指定游标类型。 2. **odbc_...
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. ...
4. **结果集处理优化**:如使用`ResultSet.TYPE_FORWARD_ONLY`和`ResultSet.CONCUR_READ_ONLY`模式,减少内存占用。 5. **异常处理**:正确捕获和处理SQLException,确保程序健壮性。 总的来说,JDBC提供了一套标准...
* 可滚动的 Statement 不能执行 SELECT MAX(ID) 之类的查询语句(SQLServer 2000) * * @param sql * 需要执行的 SQL * @return 记录总数 */ public int getAllCount(String sql) { try { Statement ...
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...
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 ...
- **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. - **...
包含如下操作系统版本 FreeBSD Linux Solaris Windows 分别对应如下目录 MegaCLI for DOS MegaCLI for Linux MegaCLI for Solaris MegaCLI for FreeBSD MegaCLI for Windows ********************************...
// iteration is forward only while (cursor.hasNext()) { console.log(cursor.next()); } // use first(), last() and all() to retrieve matched objects cursor.first(); cursor.last(); ...
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 ...
- 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#...
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 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 ...
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 ...
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 ...
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 ...
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), ...