|
Heavyweight servers treat Blobs, and Clobs have their own characteristics
Therefore, at this time, there will be differences between the JDBC and JNDI database operations, and it does not matter if the database is exported
The next section of Coding hopes to help you
//Get database connection through JNDI
Context context = new InitialContext();
ds = (DataSource) context.lookup("ORA_JNDI");
Connection con = ds.getConnection();
con.setAutoCommit(false);
Statement st = con.createStatement();
//Insert an empty object empty_clob()
st.executeUpdate("insert into TESTCLOB (ID, NAME, CLOBATTR) values (1, "thename", empty_clob())");
//Lock the data row for update, pay attention to the "for update" statement
ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1 for update");
if (rs.next())
{
//Forcibly convert to weblogic.jdbc.vendor.oracle.OracleThinClob after obtaining the java.sql.Clob object (different App Server may correspond to different)
weblogic.jdbc.vendor.oracle.OracleThinClob clob = (weblogic.jdbc.vendor.oracle.OracleThinClob) rs.getClob("CLOBATTR");
Writer outStream = clob.getCharacterOutputStream();
//data is the incoming string, definition: String data
char[] c = data.toCharArray();
outStream.write(c, 0, c.length);
}
outStream.flush();
outStream.close();
con.commit();
con.close(); |
|