斑竹!!!!7天了~~~~~~~~~~~~~~

henry_t 2002-05-29 08:25:34
我用jspsmartupload处理上传,大家知道上面有例子,是关于mysql的,我用的是oracle,所以把驱动改了,表的结构和字段一模一样。如下:

<%@ page language="java" import="java.sql.*,oracle.sql.*,com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />

<HTML>
<BODY BGCOLOR="white">

<H1>jspSmartUpload : Sample 4</H1>
<HR>

<%
//ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE
// Variables
int count=0;

// Connect to the database
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@www.ffff.org:1521:oracle","fff","fff");

// SQL Request
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT * FROM TFILES WHERE ID=1");

// if the resultset is not null
if (rs.next()){

// Initialization
mySmartUpload.initialize(pageContext);

// Upload
mySmartUpload.upload();

// upload file in the DB if this file is not missing
if (!mySmartUpload.getFiles().getFile(0).isMissing()){

try {

rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(0).getFileName());

// Add the current file in the DB field
mySmartUpload.getFiles().getFile(0).fileToField(rs,"FILE");

// Update
rs.updateRow();
count++;

} catch(Exception e) {
out.println("An error occurs : " + e.toString());
}

}

}

// Display the number of files uploaded
out.println(count + " file(s) uploaded in the database.");

rs.close();
stmt.close();
con.close();

%>

</BODY>
</HTML>



异常如下:




An error occurs : java.sql.SQLException: Invalid operation for read only resultset: updateString 0 file(s) uploaded in the database



怎么回事?明明Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);

原来的例子(mysql)用得很顺利。

被蹩得没法子了,大家能体会我的心情吧,帮我分析一下,看是什么问题,
我以为是驱动不支持结果集可修改,可换了两个还是劳样子,是这问题吗?
如果谁的办法能帮我解决,我发毒誓给至少500,发新贴给!!!当然
空口无凭,但请相信我!!!!!!!!!!!
...全文
2 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhu_liping 2002-05-30
Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
回复
leonzhao 2002-05-30
在你的select语句后加for update

如:SELECT * FROM TFILES WHERE ID=1 for update
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告