[Java]/***** @ param query indicates the SQL statement * @ param idForQuery identifies the primary key * @ param value indicates the string data to be written * @ throws Exception */public static void writeBlobGBKBinaryStream (String query, int idForQuery, String value) throws Exception {PreparedStatement p = null; ResultSet rs = null; OutputStream blobWriter = null; try {p = JForumExecutionContext. getConnection (). prepareStatement (query); p. setInt (1, idForQuery); rs = P.exe cuteQuery (); rs. next (); Blob text = rs. getBlob (1); // obtain the first blob type field here. if you know the name of this field, you can also use this name if (text instanceof BLOB) {blobWriter = (BLOB) text ). getBinaryOutputStream (); // get the byte output stream} else {blobWriter = text. setBinaryStream (0);} blobWriter. write (value. getBytes ("GBK"); // write data blobW blobWriter. close ();} catch (IOException e) {throw new DatabaseException (e);} finally {if (blobWriter! = Null) {blobWriter. close ();} DbUtils. close (rs, p) ;}}note the following points: 1. This method can insert only one record, but not insert but update, because before calling this method, the table already contains a piece of data, and its blob field is null. Fill in the null value here. 2. the query parameter is a select parameter instead of an insert or update parameter. For example, SELECT vblob FROM pub_t_bu_image where datakey =? For update, do not forget for update. After the query is executed, do not forget rs. next () to locate the record. 3. Multiple blob data can be added to a record. Blob text = rs. getBlob (1); can be understood as in the select statement, I want to obtain the first blob type field. If there are multiple blob type fields, you can set different numbers. If you know the field name clearly, you can also use it directly. 4. Get the stream getBinaryOutputStream (). This method is in the oracle. SQL package and must be imported first. In addition, you need to verify whether the type is blob. It is similar in reading. We will not repeat it again, but pay attention to the same encoding method.