社区
Web 开发
帖子详情
怎样用jspsmartupload将一个文件存入数据库(sqlserver2000)
xiaoxion
2002-01-23 08:01:43
怎样用jspsmartupload将一个文件存入数据库(sqlserver2000),恳请想告,分数如是奉上
...全文
97
3
打赏
收藏
怎样用jspsmartupload将一个文件存入数据库(sqlserver2000)
怎样用jspsmartupload将一个文件存入数据库(sqlserver2000),恳请想告,分数如是奉上
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
weidegong
2002-04-27
打赏
举报
回复
我也补个问题,如何将上传文件通过SQL语句的形式存入数据库哪?
Connection con=conPDM.getConn();
PreparedStatement pstmt=con.prepareStatement(strSQLAdd);
for(int i=0;i<mySmartUpload.getFiles().getCount();i++){
java.io.File file=mySmartUpload.getFiles().getFile(i);
FileInputStream fis = new FileInputStream(file);
pstmt.setBinaryStream(i+1,fis,file.getSize() );
}//end for(int i=0;...为pstmt设置参数完成
pstmt.executeUpdate();
这样不太对呀
weidegong
2002-04-27
打赏
举报
回复
<%@ page language="java" import="java.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>
<%
// Variables
int count=0;
// Connect to the database
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql:///test");
// 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>
zhjx_10
2002-01-23
打赏
举报
回复
看看它的sample
oracle先排序然后再从排序后的数据中取前几条
oracle先排序然后再从排序后的数据中取前几条 select * from (select * from t order by col1) where rownum<10
oracle共几条当前几条,Oracle 以某字段分组,以某字段排序,取前几条
select * from (select row_number() over(partition by 以此字段为分组 order by 以此字段排序 desc rnfrom dual) where rn=1 --表示取第
一个
如:id date1 11/041 11/081 11/122 11/032 11/01结果id date1 11/122 11/03...
Oracle查询分组排序取前几条
Oracle查询分组排序取前几条
Oracle 以某字段分组,以某字段排序,取前几条
有事你发现group by查询的时候如果想显示不分组的字段不好写,必须跟着group by后面才能能...,利用分区可以实现不用既有group by的效果又可以显示不用分组的字段...(分区实现)sql如下:select * from (select 表.*, row_number() over(partition by 分组字段 order by 排序字段 desc) rn from 表) w...
Web 开发
81,111
社区成员
341,726
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章