Data is too long, the problem cannot be inserted into the database

zhaozj2021-02-16  62

This problem is also a different type of data, different databases, and different field types of different fields.

We take an Oracle database as an example.

Assume that the name of the storage field is Field1, type is varchar2 (4000),

At this time, theory of theory can be inserted into 4000 characters or 2000 Chinese, but when the database is actually inserted,

The actual character depends on the platform, version, and the size of the PGA in the SGA.

Take the company database development environment with Epson second phase: PIII900, RAM256, Oracle8.17, SGA 300M as an example,

When using Statement as a database to operate the container, directly to the Field1 insert can cause the PGA to increase, it is possible to cause the database Crash

When using PrepareStatement as a database to operate the container, in Field1 is VARCHAR2 (4000), the usual operation is no problem.

When the type of Field1 is a long type,

At this time, the theory is the case that can be inserted into 2G characters or 1G, but when the database is actually inserted,

When operating the container as a database with StateMetn, the direct insertion of the same type of varchar2 (4000) is inserted.

When using PrepareStateMTN as a database to operate the container, the usual operation can only be inserted into data within the length of 1567 characters, at this time,

We solve problems in a flow mode (as described).

to sum up:

When we set a field to the long field for other big fields, we can use a streaming to perform database operations, but at this time, we have lost

Correct

This field uses the conditional query, create an index, and so on.

This issue occurs in many, such as background / department announcement, industry news, etc.

The corresponding field in the database is VARCHAR2 (4000), but the data length exceeds 700 and cannot be inserted.

PREPAREDSTATEMT PSTMT;

String content;

problem causes:

PSTMT.SetString (1, content);

If Content is too long, inserting a database cannot be successful.

Solution:

PSTMT.SetCharacterstream (1, New java.io.stringreader (content), content.length ());

success.

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

New Post(0)