Analysis: The large text in Oracel cannot be inserted directly because Oracle will automatically convert CLOB to string, when the text byte exceeds 4000 bytes, the hint character is too long.
Note:
GBK encoding: A kanji account of two bytes .
UTF-16 encoding: Usually Chinese characters account for two bytes,CJKV expand Area B, expand C , expand D area of Kanji to four bytes (Unicode for general characters The range is u+0000 to u+ffff, and the extents of these extensions are greater than u+20000, thus using two UTF-16).
UTF-8 Encoding (variable length encoding): Usually Chinese characters account for three bytes , and the Chinese characters after the expansion of area B account for four bytes.
ASCII code occupies one byte of one character
GB2312 Code 1 characters 2 bytes therefore: Oracel store only 4000/(3*2) = 666 kanji in UTF-8 way, GBK storage 4000/2=2000
Solution: Stream by Stream
Package oracel_test;
Import java.io.IOException;
Import Java.io.StringReader;
Import java.sql.Connection;
Import Java.sql.Date;
Import Java.sql.DriverManager;
Import java.sql.PreparedStatement;
Import java.sql.SQLException;
Import java.text.ParseException;
Import Java.text.SimpleDateFormat;
public class ClobTest3 {
@SuppressWarnings ("deprecation")
public static void Main (string[] args) throws SQLException, ClassNotFoundException, IOException, parseexception {
String Context1 = "1022288Java is an object-oriented programming language that absorbs not only the advantages of the C + + language, but also the many inheritance, pointers and other concepts that are difficult to understand in C + +, so the Java language has two features that are powerful and easy to use. [1] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [10] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [9] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [8] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [7] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [6] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [5] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [4] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [3] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [2] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [1] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. ";
String context2 = "10222233Java is an object-oriented programming language that absorbs not only the advantages of the C + + language, but also the many inheritance, pointers and other concepts that are difficult to understand in C + +, so the Java language has two features that are powerful and easy to use. [1] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [10] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [9] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [8] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [7] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [6] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [5] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [4] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [3] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [2] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. "
+ "Java is simple, object-oriented, distributed, robust, security, platform independence and portability, multi-threading, dynamic and other characteristics [2]. Java can write desktop applications, Web applications, distributed systems and embedded system applications such as Java is an object-oriented programming language, not only absorbs the various advantages of the C + + language, but also rejects the C + + difficult to understand the concept of multiple inheritance, pointers, etc. As a result, the Java language has two features that are powerful and easy to use. [1] The Java language, as the representative of the static object-oriented programming language, implements the object-oriented theory very well and allows programmers to do complex programming in an elegant way of thinking. ";
String url = "Jdbc:oracle:thin: @localhost: 1521:cqs";
String user = "Jition";
String password = "Jition";
Class.forName ("Oracle.jdbc.OracleDriver");
Connection conn = drivermanager.getconnection (URL, user, password);
Conn.setautocommit (FALSE);
String stringdate = "";
String insertsql = "INSERT into context (Id,context,name,create_date) VALUES (?,?,?,?)";
PreparedStatement PS = conn.preparestatement (insertsql);
Ps.setint (1, 11112222);
Working with CLOB objects
StringReader reader1 = new StringReader (CONTEXT1);
StringReader reader2 = new StringReader (CONTEXT2);
Ps.setcharacterstream (2, Reader1, Context1.length ());
Ps.setcharacterstream (3, Reader2, Context2.length ());
if (stringdate! = null &&!stringdate.equals ("")) {
Java.util.Date Date = new SimpleDateFormat ("Yyyy/mm/dd"). Parse (stringdate);
Ps.setdate (4, New Date (Date.gettime ()));
} else {
Ps.setdate (4, NULL);
}
Ps.executeupdate ();
Conn.commit ();
Conn.close ();
}
}
Operation Clob Large object in Java, prompting ORA-01704 string literal too long