Oracle processes Clob data warehouse receiving (String warehouse receiving)
You can search for a bunch of references from the Internet, either in unknown or not. You can load a pile of data into the database. Please refer to the final:
Insert into CP_V_INFO "+
"(ID," +
"PROJECT_ID," +
......
"V_INFO," +
......
"VERSION) values (?,?,?,?,?,?,?,?,?,?, "+
"?,?, EMPTY_CLOB (),?,?,?,?,?,?,?, "+
"?,?,?,?,?,?,?,?,?,?, "+
"?) ";
This.cdcDao.exe cuteSQL (SQL, v7Info. getId (),
V7Info. getProjectId (),......
);
// Insert the data first and use EMPTY_CLOB () to insert the data in this field.
// Then for update
String update_ SQL = "select V_INFO from CP_V_INFO where ID = '" + v7Info. getId () + "' for update ";
This.cdcDao.exe cuteClobSQL (update_ SQL, "V_INFO", v7Info. getvInfoStr ());
/**
*
* @ Method: executeClobSQL
* @ Description: update the Clob field.
* @ Param update_ SQL
* @ Param column field name data the field data
* @ Return
* @ Throws SQLException
* @ Throws Exception
* @ Author liuz
* @ Date 2016-3-28
*/
Public void executeClobSQL (String update_ SQL, String column, String data) throws SQLException, Exception {
If (MyJdbcTemplate) this. getJdbcTemplate (). isNEED_ENCODE ()){
Update_ SQL = new String (Response (MyJdbcTemplate) this. getJdbcTemplate (). getAPP_ENCODE (), (MyJdbcTemplate) this. getJdbcTemplate (). getDB_ENCODE ());
}
PreparedStatement p = null;
ResultSet rs = null;
Try {
Connection conn = this. getConnection ();
Conn. setAutoCommit (false );
P = paserSQL (conn, update_ SQL );
Rs = conn.createstatement(.exe cuteQuery (update_ SQL );
If (rs. next ()){
/* Retrieve the CLOB object */
Oracle. SQL. CLOB clob = null;
Clob = (oracle. SQL. CLOB) rs. getClob (column );
/* Write data to the CLOB object */
BufferedWriter out = new BufferedWriter (clob
. GetCharacterOutputStream ());
Out. write (data );
Out. flush ();
Out. close ();
}
Rs. close ();
Conn. commit ();
Conn. setAutoCommit (true );
} Finally {
If (rs! = Null ){
Try {
Rs. close ();
} Catch (SQLException e ){
E. printStackTrace ();
}
}
If (p! = Null ){
Try {
P. close ();
} Catch (SQLException e ){
E. printStackTrace ();
}
}
}
}
After numerous difficulties, my colleagues said, "Why should I change the underlying code ?". After a pleasant keyboard sound, the original method was changed. This field is inserted normally with a String. The result is: the database is imported normally. , And tears !!!!
String SQL = "insert into CP_V_INFO" +
"(ID," +
......
"V_INFO," +
......
"VERSION) values (?,?,?,?,?,?,?,?,?,?, "+
"?,?,?,?,?,?,?,?,?,?, "+
"?,?,?,?,?,?,?,?,?,?, "+
"?) ";
This.cdcDao.exe cuteSQL (SQL, v7Info. getId (),
......
V7Info. getvInfo (), // String type
......
V7Info. getVersion ());
/********* End **********/