This switched https://www.cnblogs.com/yingsong/p/5685790.html
Reason : This is a field varchar2 (1024), but the actual value to be inserted exceeds the maximum length allowed when varchar2 4000, oracle automatically compares the value is converted to a Long, then prompted to insert the operation failed.
Solution:
1) is not really want to insert the value exceeds the defined length? Length or to make a judgment, interception.
2) If so, then the field using clob, blob, or use the file instead, save the file field address.
For clob, blob
CLOB defined
A type of database used to save the file.
Character Large Object
SQL type CLOB mapping in the JavaTM programming language. SQL CLOB is a built-in type that character large object (Character Large Object) is stored as a column value in a row in the database table. By default, driver uses SQL locator (CLOB) Clob object achieved, which means CLOB a logical pointer to the object contains the SQL CLOB data rather than the data itself. Clob object is valid during a transaction it was created.
In some database systems, also uses the alias Text as CLOB, such as SQL Server
BLOB meaning
BLOB (binary large object), binary large object, a container can store binary files.
In the computer, BLOB field type is often used to store a database of binary files.
BLOB is a large file, typically BLOB is a picture or a sound file, because of their size, must use a special way to deal with (for example: upload, download, or stored in a database).
According to Eric Raymond's statement, the main idea is to make the process BLOB file processor (such as a database manager) ignore what files are, but about how to deal with it.
Nevertheless, some experts stress that this method to handle large data object is double-edged sword, it may lead to some problems, such as the storage of large binary files, database performance will decline. Storing bulky objects in the database is a multimedia application processing Typical examples of the BLOB.
The difference between the BLOB and CLOB
CHAR CLOB use to store data. Such as: save the XML document.
BLOB is a binary save the data. Such as: Save bitmap.
Inside the operation of the JAVA CLOB
In most cases, using two methods of using CLOB
1 is relatively small
Direct manipulation can String, as the string type to CLOB
2 If relatively large
1) If the jdbc, or may be getAsciiStream getUnicodeStream and corresponding to setAsciiStream and setUnicodeStream)
2) clob how and Hibernate with (refer to the original: http: //www.tuicool.com/articles/fumQfe)
a) Assignment mode attribute type Clob - String turn Clob :
Content request.getParameter = String ( "Content"); // value. 1 (String type) the request from the request.
The Clob = Hibernate.createClob CLOB (Content); . 2 // hibernate through the string into CLOB
News. the setContent (CLOB); .. 3 // class corresponds to an entity attribute assignment
b) the value of the attribute type Clob manner - Clob turn String :
List <News> . Query.addEntity List = (News.class) List (); // value from the database. 1. News = News (News) List.get ( 0); . News Object // 2 taken String content = ClobUtil.ClobToString (news.getContent ()); .. 3 // object clob the news content is converted to type string string
----------------- ClobUtil -----------------------. 1 2 . 3 ClobUtil {public class . 4 public String ClobToString static (the Clob CLOB) { . 5 clobStr String = ""; . 6 Reader IS = null; . 7 the try { . 8 Clob.getCharacterStream IS = (); . 9 // resulting stream 10 the BufferedReader the BufferedReader br = new new (IS); . 11 String null = S; 12 is br.readLine S = (); 13 is new new StringBuffer StringBuffer SB = (); 14 // remove all the execution cycle of the string assigned to StringBuffer, StringBuffer turn into a string 15 the while (S = null!) { sb.append 16 (S); . 17 br.readLine S = (); 18 is} . 19 clobStr sb.toString = (); } The catch 20 is (IOException E) { 21 is e.printStackTrace (); 22 is} the catch (SQLException E) { 23 is e.printStackTrace (); 24} 25 return clobStr; 26 is} 27} 28 29 Note: read through the flow way Clob data type