求教:关于(lob)
当用JAVA向oracle插入blob/clob时,超过一M就出现
org.apache.jasper.JasperException: ORA-01691: Lob 段FEIYUE.SYS_LOB0000024945C00002$$无法通过128(在表空间FEIYUE中)扩展
ORA-06512: 在"SYS.DBMS_LOB", line 708
ORA-06512: 在line 1
为什么呢???难道oracle不允许一次插入1M以上的文件吗?
代码如下
<%@page language="java" import="com.jspsmart.upload.*" contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<jsp:useBean id="myUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<HTML>
<BODY BGCOLOR="white">
<H1>jspUpload : Sample</H1>
<HR>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbcracle:thin:@202.1.116.51:1521:rc";
String user="rc";
String passwd="rc";
Connection conn=DriverManager.getConnection(url,user,passwd);
conn.setAutoCommit(false);
ResultSet rs=null;
Statement stmt=conn.createStatement();
myUpload.initialize(pageContext);
myUpload.upload();
myUpload.save("/");
int i;
com.jspsmart.upload.File myFile = myUpload.getFiles().getFile(0);
String fileName = myFile.getFileName();
if (!myFile.isMissing()) {
//save data
myFile.saveAs(fileName, myUpload.SAVE_PHYSICAL);
java.io.File file = new java.io.File(fileName);
java.io.BufferedInputStream inStream = new BufferedInputStream(new java.io.FileInputStream(file));
int fileSize = myFile.getSize();
byte[] bytes = new byte[fileSize];
//将数据插入到表中
String strSql = "insert into test(name,testfile) values('" + fileName + "',empty_blob())";
stmt.execute(strSql);
rs = stmt.executeQuery("select testfile from test where name='" + fileName + "' for update ");
System.out.println("pass");
if (rs.next()) {
oracle.sql.BLOB blob = ( (oracle.jdbc.OracleResultSet) rs).getBLOB("testfile");
BufferedOutputStream outStream = new BufferedOutputStream(blob.getBinaryOutputStream());
System.out.println("pass2");
while((i=inStream.read(bytes))!=-1)
{ outStream.write(bytes);
inStream.read(bytes);}
System.out.println("pass3");
outStream.flush();
stmt.execute("commit");
outStream.close();
}
inStream.close();
stmt.close();
if(file!=null)//删除文件
file.delete();
out.println("upload sucess");
} else {
out.println("no file");
}
%>
</BODY></HTML>