关于Blob类型的数据存储,在线急等
本帖最后由 shaojiexu15 于 2013-08-09 18:17:26 编辑
一个字符串,存储了将近几千汉字
怎么样将其添加到相应的表里面
public boolean doAdd(Law law) throws Exception {
IDbOperator dbop = DBOperator.getInstance();
StringBuilder sql = new StringBuilder();
boolean key = false;
List<DbSqlParameter> sqlParam = new ArrayList<DbSqlParameter>();
sql.append(" insert into T04_Law (LAWID, LAWTITLE, LAWBELONG, LAWCONTENT, DELFLAG, CREATEUSERID, CREATEDATE, UPDATEUSERID, UPDATEDATE, DELUSERID, DELDATE) ");
sql.append(" values (?, ?, ?, ?, ?, ?, to_date(?, 'yyyy-MM-dd hh24:mi:ss'), ?, to_date(?, 'yyyy-MM-dd hh24:mi:ss'), ?, to_date(?, 'yyyy-MM-dd hh24:mi:ss')) ");
sqlParam.add(new DbSqlParameter("LAWID", CommonUtil.getUUID()));
sqlParam.add(new DbSqlParameter("LAWTITLE", law.getLawTitle()));
sqlParam.add(new DbSqlParameter("LAWBELONG", law.getLawBelong()));
sqlParam.add(new DbSqlParameter("LAWCONTENT",
law.getLawContent().trim().getBytes("GBK")));
sqlParam.add(new DbSqlParameter("DELFLAG", law.getDelFlag()));
sqlParam.add(new DbSqlParameter("CREATEUSERID", law.getCreateUserId()));
sqlParam.add(new DbSqlParameter("CREATEDATE", CommonUtil.GetCurrentDate()));
sqlParam.add(new DbSqlParameter("UPDATEUSERID", ""));
sqlParam.add(new DbSqlParameter("UPDATEDATE", ""));
sqlParam.add(new DbSqlParameter("DELUSERID", ""));
sqlParam.add(new DbSqlParameter("DELDATE", ""));
// sql.append(" declare ");
// sql.append(" v_clob clob :='"+law.getLawContent()+"'; ");
// sql.append(" begin ");
// sql.append(" insert into T04_Law values ('"+CommonUtil.getUUID()+"', '"+law.getLawTitle()+"', '"+law.getLawBelong()+"', :clob, 0, '"+law.getCreateUserId()+"', to_date('"+CommonUtil.GetCurrentDate()+"', 'yyyy-MM-dd hh24:mi:ss'), '', '', '', ''); ");
// sql.append(" end; ");
try {
// int cnt = dbop.ExecuteUpdate(sql.toString());
int cnt = dbop.ExecuteUpdate(sql.toString(), sqlParam);
if (cnt > 0) {
dbop.CommitTransaction();
key = true;
} else {
dbop.RollbackTransaction();
key = false;
}
} catch (Exception e) {
key = false;
e.printStackTrace();
throw e;