您的位置:首页 > 数据库 > Oracle

Java将数据写入Oracle的Clob字段中

2013-01-15 15:21 405 查看
---------------------将大量数据写入Clob字段中-------------

一。得到连接

def dbDriver = "oracle.jdbc.driver.OracleDriver";

def url = "jdbc:oracle:thin@xxx

def username = "foi";

def password = "foi";

Connection conn = null;

Class.forName(dbDriver);

DriverManager.setLoginTimeout(30);

conn = DriverManager.getConnection(url, username, password);

二。写sql语句

def sql=""" update notice set title=?,publish_time=?,info_body=? where id=1""";

三。预编译

def title=params.title;

def infoBody=params.infoBody;

def publishTime="2012-12-12"

def pstm=conn.prepareStatement(sql);

Reader clobReader = new StringReader(infoBody);

pstm.setString(1,title);

pstm.setString(2, publishTime);

pstm.setCharacterStream(3, clobReader,infoBody.length());

pstm.executeUpdate();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: