我是从asp转过来的,感觉到jsp确实比asp麻烦很多。我在asp中改写稻香老农的伍组建上传很容易就能实现上传直接保存到oracle的blob中,可是在jsp中我改写jspsmartupload就没那么轻松了。代码如下:
在XX.jsp中
String query = "INSERT INTO T_DOCTYPE (TYPESORT,TYPEID,TYPENAME,CONTENT,USERID)VALUES ( ' " +TYPESORT+ " ', ' "+ docid + " ', ' " + TYPENAME + " ', EMPTY_BLOB(), ' " + userID + " ') ";
java.sql.PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.executeUpdate();
String sql = "update T_DOCTYPE set CONTENT where WHERE TYPEID= ' " + docid + " ' " ;
pstmt = conn.prepareStatement(sql);
//query = "SELECT CONTENT FROM T_DOCTYPE WHERE TYPEID= ' " + docid + " ' FOR UPDATE ";
//java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
//ResultSet rs = stmt.executeQuery(query);
try{
myFile.fileToBlob(pstmt);
}catch(Exception ex){
ex.printStackTrace();
}
smartupload的file.java中增加
public void fileToBlob(java.sql.PreparedStatement rs)
throws SQLException, SmartUploadException, IOException, ServletException
{
long numBlocks = 0L;
int blockSize = 0x10000;
int leftOver = 0;
int pos = 0;
if(rs == null)
throw new IllegalArgumentException( "The RecordSet cannot be null (1145). ");
if(columnName == null)
throw new IllegalArgumentException( "The columnName cannot be null (1150). ");
if(columnName.length() == 0)
throw new IllegalArgumentException( "The columnName cannot be empty (1155). ");
numBlocks = BigInteger.valueOf(m_size).divide(BigInteger.valueOf(blockSize)).longValue();
leftOver = BigInteger.valueOf(m_size).mod(BigInteger.valueOf(blockSize)).intValue();
try