import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import oracle.jdbc.driver.OracleDriver;
import oracle.sql.CLOB;
private void clobImport() throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stubDriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(url, user, pwd);// 得到连接对象
String sql = "insert into clob_test(id,str) values ('1',?)";// 要执行的SQL语句
PreparedStatement stmt = conn.prepareStatement(sql);// 加载SQL语句
// PreparedStatement支持SQL带有问号?,可以动态替换?的内容。
Reader clobReader = new StringReader(text); // 将 text转成流形式
stmt.setCharacterStream(1, clobReader, text.length());// 替换sql语句中的?
int num = stmt.executeUpdate();// 执行SQL
if (num > 0) {
System.out.println("ok");
}
}
转自:http://blog.sina.com.cn/s/blog_5045c0920100acau.html