Pra*_*ati 0 java sql sql-server-2005 jdbc oracle10g
上述查询在 Oracle 10g 上成功运行。现在我必须使用 SQLSERVER 2005 实现相同的查询(应用程序)。
当我在 SQLSERVER 2005 中运行上述查询时,出现错误“FOR UPDATE 子句仅允许用于 DECLARE CURSOR”。
SQLSERVER 2005 支持上述查询吗?或者有什么替代方案吗?
目的:
基本上我正在更新我的应用程序中的文档。我正在使用分块更新,每次都必须将旧内容附加到新内容。
代码:
Blob bb = getDataAccess().executeScalar( "select content from Repository where id = ? for update", getId());
os = bb.setBinaryStream(startIndex + 1);
while ((read = content.read(buf)) > 0) {
os.write(buf, 0, read);
startIndex += read;
//commit every megabate or every second so upload progress is visible
//and we don't lose more than 1MB if something happens.
if (startIndex - lastStartIndex > bufSize || (new Date().getTime() - lastUpdateTime) > UPDATE_INTERVAL) {
os.close();
os = null;
getDataAccess().executeUpdate("UPDATE Repository SET LastChunkSaved = CURRENT_TIMESTAMP WHERE ID = ?", getId());
getDataAccess().commit();
lastStartIndex = startIndex;
lastUpdateTime = new Date().getTime();
bb = getDataAccess().executeScalar( "select content from Repository where id = ? for update", getId());
os = bb.setBinaryStream(startIndex + 1);
totalSaved += startIndex - lastStartIndex;
}
}
os.close();
Run Code Online (Sandbox Code Playgroud)
我遇到了类似的问题,对我来说,它有助于将“SelectMethod=Cursor”添加到连接网址:
jdbc:sqlserver://<server>\SQLEXPRESS:1433;databaseName=<db>;SelectMethod=Cursor;integratedSecurity=true;
Run Code Online (Sandbox Code Playgroud)
实际上我不太容易找到它,所以我将它添加到这里,这样我可以更快地找到它。
| 归档时间: |
|
| 查看次数: |
2302 次 |
| 最近记录: |