How to use JSP to handle fields in Oracle in Oracle

xiaoxiao2021-03-06  76

1. Insertion of the Clob field

The CLOB type data directly insert may be in the form of an object because the characters are too long.

Example:

First, create a table with a clob field:

Create Table Test (ID Integer, Content Clob);

Then insert a null value

String strsql = "INSERT INTO TEST (ID, Content) VALUES ('0001' ,?)";

Con.SetAutocommit (false); // conn is the Connection object

// Create and instantiate a CLOB object

Clob Clob = New Clob (ORACLECONNECTION) Con);

Clob = Oracle.Sql.Clob.createTemporary (ORACLECONNECTION) CON, TRUE, 1);

/ / Assign a value for the CLOB object

Clob.putString (1, Formatesinglequotes);

OracleConnection Ocon = (ORACLECONNECTION) CON;

OraclePreparedStatement PSTMT = (ORACLEPREPAREDStatement) Ocon.prepareCall (strsql);

PSTMT.SETCLOB (1, Clob);

INT i = pstmt.executeUpdate ();

PSTMT.Close ();

Ocon.commit ();

Ocon = NULL;

CON = NULL;

Boolean flag = true;

IF (i <= 0)

{

Flag = false;

}

IF (Flag == True)

{

Out.print ("