Java language Operates the CLOB data type in the Oracle database

zhaozj2021-02-16  62

Related information about Oracle fields You can check the Oracle Technology Network. Some of the descriptions of types related to blob.clob are extracted below. It is convenient for everyone's understanding. Field Type: BLOB, Clob, NClob Description: Three large objects (LOB), used to save large graphics files or format text files, such as Miceosoft Word documents, and audio, video, etc. non-text files, the maximum length is 4GB. There are several types of LOB depends on the type of the byte you use, and Oracle 8i is actually stored in the database inside the database. Special operations such as read, storage, write, etc. can be performed.

The attribute we operate is (character ID, Clob type picstr), and we now assume that a large character object STR already contains data we need to store the PICSTR field. And the Connection object CONN has been established. The following example programs are also not written by throwing exceptions because they don't want to take up too much space. Let's refer to the API DOC. You can know what abnormally throws, just tell you how to write.

Code: (1) Insert operation of database CLOB type ******************************************************** *********** java.sql.preparedStatement PSTMT = NULL; ResultSet RS = NULL; STRING Query = ""; conn.setautocommit (false); query = "Insert Into Clobtest_Table (ID, PICSTR) VALUES (?, empty_clob ()) "; java.sql.PreparedStatement pstmt = conn.prepareStatement (query); pstmt.setString (1," 001 "); pstmt.executeUpdate (); pstmt = null query =" select picstr from clobtest_table WHERE ID = '001' for update "; pstmt = con.preparestatement (query) = pstmt.executeQuery (); oracle.sql.clob clobtt = null; if (rs.next ()) {Clobtt = (Oracle.sql .Clob) gtClob (1);} WRITER WR = Clobtt.getCharacterOutputStream (); wr.write (); wr.flush (); wr.close (); rs.close (); con enride () (2) Whether the database has been successfully inserted into the database ******************************************** ************* PL / SQL package dBMS_LOB to process LOB data. Check if the insertion of the initial insert is successful. Use the GetLength this procedure with the DBMS_LOB package to detect if the STR has been stored in the PICSTR field. Such as: SQL> SELECT DBMS_LOB.GETLENGTH (PICSTR) from clobtest_table; (3) Perform reading operations for database CLOB type ************************ *********************** is very simple to read relative insertions. Basic steps and half of the database data is not too big.

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

New Post(0)