JSP
| 2007-05-16 23:46:55
ÆÄÀϾ÷·Îµå´Â apache ÆÄÀϾ÷·Îµå ÀÌ¿ë..
À̸§Àº »ý°¢ÀÌ ¾È³².¤Ñ.¤Ñ
<%!
public String getClobdata(Reader r) throws IOException
{
if(r!=null)
{
char[] buff = new char[512];
int len = -1;
String clobValue;
StringBuffer buffer = new StringBuffer(512);
while( (len = r.read(buff)) != -1) {
buffer.append(buff, 0, len);
}
clobValue = buffer.toString();
return clobValue;
} else {
return "";
}
}
public StringBuffer setStringCLOB(String str) throws SQLException
{
StringBuffer sb = new StringBuffer();
if(str!=null)
{
sb.append(str);
} else {
sb.append("");
}
return sb;
}
public void Bufferwrite(CLOB cl , StringBuffer str) throws SQLException,IOException
{
BufferedWriter writer = new BufferedWriter(cl.getCharacterOutputStream());
writer.write(str.toString());
writer.close();
}
%>
sb.append(data.getWr_content());
cstmt=conn.createStatement();
crs=cstmt.executeQuery("select WR_CONTENT,b_file from "+boTable+" where NUM = '"+num+"' for update");
if(crs.next())
{
CLOB CL = ((OracleResultSet)crs).getCLOB("WR_CONTENT");
oracle.sql.BLOB blob = ((OracleResultSet)crs).getBLOB(2);
BufferedWriter writer = new BufferedWriter(CL.getCharacterOutputStream());
writer.write(sb.toString());
writer.close();
if (filename !=null) //ÆÄÀÏÀÌ ÀÖÀ¸¸é
{
File binFile = uploadedFile;
FileInputStream instream = new FileInputStream(binFile);
OutputStream outstream_blob = blob.getBinaryOutputStream(); //Insert to the BLOB from an output stream.
//Read the input stream and write the output stream by chunks.
byte[] chunk = new byte[blob.getChunkSize()];
int j=-1;
System.out.println("Loading");
while((j = instream.read(chunk))!=-1)
{
outstream_blob.write(chunk,0,j);
System.out.print('.');
}
instream.close();
outstream_blob.close();
}
}
conn.commit();
conn.setAutoCommit(true);