jspsmartupload问题(请教各位大大,特别是rinring大侠):

dengmj 2002-03-30 10:11:46
我的环境是win2000,jdk1.3.1_02,tomcat4.0,数据库是SQL SERVER 2000,我设的FILEDATA为IMAGE类型来存储文件,可我用他的测试用例SAMPLE4.HTM,上传文件到数据库,可是不行,老是报 java.lang.NullPointerException 0 file(s) uploaded in the database. 他的代码我只该了一点点,就是连接数据库,和一个字段名。
<% // Variables
int count=0;
// Connect to the database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:odbc:PTOP_OA","sa","");
// 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()){
rs.getstring("ID");
// 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_DATA");
// 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();
%>
...全文
3 点赞 收藏 1
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dengmj 2002-03-30
快点帮忙啊
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

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