---
title: "关于JDBC不支持ResultSet.last()等方法的解决"
author: "txf2004"
date: "2006-12-19T21:13:00Z"
tags: []
slug: "jdbc-resultset-last"
draft: false
lastmod: "2006-12-19T21:13:00Z"
id: 610347
url: "https://txf2004.iteye.com/blog/610347"
---

现象：使用微软的JDBC for SqlServer sp3却发现不支持ResultSet.last(),ResultSet.beforeFirst() 等方法，每次一调用这些方法就出现异常，异常信息是：java.sql.SQLException: \[Microsoft]\[SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.last

解决：Statement变量要按照如下设置

stmt = conn.createStatement(**ResultSet.TYPE\_SCROLL\_SENSITIVE**, ResultSet.CONCUR\_UPDATABLE);

类似的，

CallableStatement cs = conn.prepareCall("{call TESTSP}",ResultSet.TYPE\_SCROLL\_SENSITIVE,ResultSet.CONCUR\_UPDATABLE);

其中**type\_scroll\_sensitive**是个关键

字段摘要

**TYPE\_SCROLL\_SENSITIVE**

该常量指示可滚动但通常受其他的更改影响的 `ResultSet` 对象的类型。