读书人

上传ORACLE的有关问题~

发布时间: 2011-12-25 23:21:20 作者: rapoo

上传ORACLE的问题~急!!!
用jspsmartupload将文件上传至服务器,然后在服务器端将文件写入ORACLE时出错
java.sql.SQLException: Io 异常: Connection reset
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2061)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout

但是上传一个几K大小的文件则不会出错,只要文件大小大于几K就会报上面的错
文件可以传到服务器端.代码如下:
<%@ page language= "java " import= "java.util.* " pageEncoding= "gb2312 "%>
<%@ page import = "com.jspsmart.upload.* " %>
<%@ page import = "java.sql.* " %>
<%@ page import = "com.oa.common.* " %>
<%@ page import = "com.oa.dbase.* " %>

<jsp:useBean id = "fm " class = "com.oa.webfolder.FileManage " scope = "request " />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>

<title> My JSP 'doupload.jsp ' starting page </title>

<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<!--
<link rel= "stylesheet " type= "text/css " href= "styles.css ">
-->

</head>

<body>
<%
try{
// 新建一个SmartUpload对象
SmartUpload su = new SmartUpload();
// 上传初始化
su.initialize(pageContext);
//su.setAllowedFilesList( "doc,txt,jpg ");
su.setMaxFileSize(200*1024*1024);
su.setTotalMaxFileSize(200*1024*1024*20000);

su.upload();
String parentid = (String)su.getRequest().getParameter( "parentid ");
for(int i=0;i <su.getFiles().getCount();i++){
File tFile = su.getFiles().getFile(i);
if(!tFile.isMissing()){
String tFileName = tFile.getFileName();


//String suffix=tFileName.substring(0,tFileName.lastIndexOf( '. '));
String ext = su.getFiles().getFile(0).getFileExt();
int fileSize= tFile.getSize();

//保存路径
String savePth = request.getSession().getServletContext().getRealPath( "/ ")+ "upload/ ";
String trace = savePth + tFileName;

tFile.saveAs(trace,su.SAVE_PHYSICAL);

java.io.File file = new java.io.File(trace);
//java.io.FileInputStream fis = new java.io.FileInputStream(file);
java.io.DataOutputStream fileout=new java.io.DataOutputStream(new java.io.FileOutputStream(file));
java.io.FileInputStream fi=new java.io.FileInputStream(file);

byte[] fileByte = new byte[tFile.getSize()];
for(int j = 0 ;j <tFile.getSize();j++) {
fileByte[j]= tFile.getBinaryData(j);
}

int li = fi.read(fileByte,0,fileByte.length-1);
fileout.write(fileByte,0,fileByte.length-1);

String mSql = null;
PreparedStatement pstmt = null;
Connection conn = DatabaseConn.getConnection();

//com.oa.message.DatabaseConn db = new com.oa.message.DatabaseConn();
//Connection conn = db.getConnection();




mSql = "insert into OA_FILE values(?,?,?,?,?,?,?) ";
pstmt = conn.prepareStatement(mSql);
pstmt.setInt(1,fm.getMaxID());

pstmt.setInt(2,101);
pstmt.setInt(3,Integer.parseInt(parentid));

pstmt.setString(4,tFileName);

pstmt.setString(5,ext);

pstmt.setInt(6,fileSize);

pstmt.setBinaryStream(7,fi,(int)fileByte.length-1);

pstmt.execute();
conn.close();
}
}
response.sendRedirect( "mydocument.jsp ");

}
catch(Exception e){
e.printStackTrace();
}
%>

</body>
</html>
其中ORACLE中使用BLOB来存放文件内容.
请问为什么文件稍微一大就不能上传呢?急~~~


[解决办法]
没遇到过..su.setMaxFileSize(200*1024*1024);
su.setTotalMaxFileSize(200*1024*1024*20000);
是不是这给限制了?

读书人网 >Java Web开发

热点推荐