性能不会损耗太大,速度也比其他数据库快,且专门存储电影、图片等内容。
据说香港的马会录象全部是存储的。
把上传的照片存到服务器下并把路径存入数据库,读取时使用File对象根据数据库内存储的照片路径读取照片。注意from表单的这两个属性enctype="multipart/from-data" method="post"<package name="fileupload" extends="webwork-default"><interceptors>
<interceptor name="fileUpload"
class="com.opensymphony.webwork.interceptor.FileUploadInterceptor">
<param name="allowedTypes">image/jpeg/jpg/bmp</param>
<param name="maximumSize">10000000</param>
</interceptor> <interceptor-stack name="fileUploadStack">
<interceptor-ref name="fileUpload" />
<interceptor-ref name="defaultStack" />
</interceptor-stack><default-interceptor-ref name="fileUploadStack" /> </package > /**
* 上传照片方法
*/
public void fk_upload(String customer_no, File photo) {
long sta = System.currentTimeMillis()
Connection conn = null
PreparedStatement pstmt = null
FileInputStream fis = null
try {
conn = getConnection()
conn.setAutoCommit(false)
String strSQL = "UPDATE CARD_BASEINFO SET PHOTO=? WHERE CUSTOMER_NO=?"
fis = new FileInputStream(photo)
pstmt = conn.prepareStatement(strSQL)
pstmt.setBinaryStream(1, fis, fis.available())
pstmt.setString(2, customer_no)
int i = pstmt.executeUpdate()
System.out.println("=========>" + i)
conn.commit()
} catch (Exception ex) {
try {
conn.rollback()
} catch (SQLException e) {
System.out.println("回滚也异常")
}
ex.printStackTrace()
} finally {
try {
if (null != fis) {
fis.close()
}
if (null != pstmt) {
pstmt.close()
}
if (null != conn) {
conn.close()
}
} catch (Exception ex) {
System.out.println("偶也!关闭数据源出错了!")
ex.printStackTrace()
}
long end = System.currentTimeMillis() double useTime = BigDecimal.valueOf((end - sta)).divide(
BigDecimal.valueOf(1000)).setScale(2,
BigDecimal.ROUND_HALF_UP).doubleValue()
System.out.println("执行DAO时间为:" + useTime + "秒")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)