Use JSP to operate Oracle's Clob field

zhaozj2021-02-16  57

Clob is generally used to store oversized Guangxi, if 2 credit is generally blob. Suppose COL2 is a Clob: Write action: string sql = "INSERT INTO TB_COMMENDTEMP (Col1, col2) VALUES ('111',?)"; String S = "long text"; StringBufferInputStream sbin = new StringBufferInputStream (s); PreparedStatement ps = query.getPreStmt (sql); ps.setAsciiStream (1, sbin, s.length ()); int i = ps.executeUpdate (); ps .Close (); sbin.close (); if (i> 0) OK; if it is written in the binary, use FileInputStream (); rs.get serousstream (); rs.get binaryStream (); Look at their names, you know what type of data flow. If you are stored, binary files, such as graphics, executive files, compressed files are best BLOB insurance. Write and read also use binary stream, DataInputstrean and Datoutputstream. Sometimes it can be row with Unicode's character stream, but not insurance. If you are text, use Clob and long. Read and write BuffreedReader and PrintWriter more convenient. Blob: binary, if EXE, ZIPCLOB: single-word section, such as General text files. NLOB: Multi-bytecode, such as the file in the UTF format. If the file is format, if Word, EXECL, etc. If you want to keep the format, it is not destroyed, it is best to approximate the original way of Byte. Store, the shortcomings are of course the efficiency of operation (slow). Operation Clob, others can see the example of writing and reading above, as long as you pay attention to this pstmt.setbinaryStream () to rs.setasciistream (); read pstmt.getbinaryStream () Change to rs.getbinaryStream (); use Reader with Reader when reading flow from the file, do not use DatainuputStream

转载请注明原文地址:https://www.9cbs.com/read-15675.html

New Post(0)