日期:2014-05-16  浏览次数:20421 次

字符转换CLOB插入数据库
public static CLOB oracleStr2Clob(String str, CLOB lob) throws Exception { 
        Method methodToInvoke = lob.getClass().getMethod("getCharacterOutputStream", (Class[]) null); 
        Writer writer = (Writer) methodToInvoke.invoke(lob, (Object[]) null); 
        writer.write(str); 
        writer.close(); 
        return lob; 
    } 	

public static Object createOracleLob(Connection conn, String lobClassName) 
    throws Exception { 
		Class lobClass = conn.getClass().getClassLoader().loadClass( 
		        lobClassName); 
		final Integer DURATION_SESSION = new Integer(lobClass.getField("DURATION_SESSION").getInt(null)); 
		final Integer MODE_READWRITE = new Integer(lobClass.getField("MODE_READWRITE").getInt(null)); 
		Method createTemporary = lobClass.getMethod("createTemporary",new Class[] { Connection.class, boolean.class, int.class }); 
		Object lob = createTemporary.invoke(null, new Object[] { conn, false,DURATION_SESSION }); 
		Method open = lobClass.getMethod("open", new Class[] { int.class }); 
		open.invoke(lob, new Object[] { MODE_READWRITE }); 
		return lob; 
	}
?

?