public void insertUserInfo(String a, String c) throws Exception {
PreparedStatement pst = null;
ResultSet rs = null;
Connection con = null;
BufferedWriter outStream =null;
DrmSysManager drmmgr = DrmSysManager.getInstance();
DBPersistenceManager pm = drmmgr.getDBPersistenceManager("UNIEAP"); //获取数据库连接
try{con=pm.getConnection();
con.setAutoCommit(false);
GetRowID getId = new GetRowID();
String row_id = getId.getwoid("", "");
String sql = "insert into user7001(row_id,USER_NAME,USER_DATE,USER_SQL)"
+ "values('" + row_id + "','" + a + "',sysdate,empty_clob())";
pst=con.prepareStatement(sql);
pst.executeUpdate();
pst=con.prepareStatement("select user_sql from user7001 where row_ID='"
+ row_id + "' for update");
rs=pst.executeQuery();
if (rs.next()) {
//oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob("user_sql");
oracle.sql.CLOB clob=this.clobToWeblogicCLOB(rs.getClob("user_sql"));
//weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB clob=(weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB)rs.getClob("user_sql");
outStream=new BufferedWriter(clob
.getCharacterOutputStream());
// data是传入的字符串,定义:String data
outStream.write(c);
if(outStream!=null){
outStream.close();
}
con.commit();
}
}catch(Exception e){
con.rollback();
e.printStackTrace();
}finally{
//con.close();
}
}
public static oracle.sql.CLOB clobToWeblogicCLOB(Object in)
{
oracle.sql.CLOB clob=null;
if ("oracle.sql.CLOB".equals(in.getClass().getName())){
clob = (oracle.sql.CLOB)in;
}else if ("weblogic.jdbc.wrapper.Clob_oracle_sql_CLOB".equals(in.getClass().getName())){
Method method=null;
try {
method = in.getClass().getMethod("getVendorObj",new Class[]{});
}
catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch (NoSuchMethodException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
clob = (oracle.sql.CLOB)method.invoke(in,null);
}
catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return clob;
}