encountered SQLException [数据大小超出此类型的最大值: 6326];
你插入数据的某一行的某一列的数据大小超过数据库的限制!
你插入数据的某一行的某一列的数据大小超过数据库的限制!
解决方案 »
- SPRING MVC + IBATIS 问题
- EJB老是报错
- java是否有能替代JColorChooser的组件或其它替代方法,颜色板中的颜色条是阶梯状的
- 如何在Java项目中调用excel的表格控件?
- 嵌入式tomcat下strut2启动报错问题
- 请问正则中的小、中、大括号都什么意思
- 时间装换
- 使用HibernateXML映射方式,可以使用<composite-id>元素来映射复合自然键,如果用Hibernate Annotation,对应的注解是什么?
- Grails 快速开发的首选
- 重要问题:强烈给分!!!-大家用什么开发ejb?
- 当一个网站在某个的访问者很多的时候,如何来分配资源?
- ibatis sql语句 $$ ##问题
如果太长的话,建议用blob
如果用的话,pojo 中的类型还是String .hbm中的类型是text 数据库为Clob
这样就好用了
这里有你类似的问题,看看吧
http://topic.csdn.net/t/20061024/14/5105197.html
http://www.cnblogs.com/ungshow/archive/2008/10/16/1312675.html
public String insert(MetaEvent objMetaEvent){
String str="";
DBTool db=null;
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
try{
db=new DBTool();
con=db.connection();
con.setAutoCommit(false);
//获取下一个序列值
Long lId=0L;
String s ="select S_Event_ID.NEXTVAL from dual";
ps = con.prepareStatement(s);
rs = ps.executeQuery();
if(rs.next())
{
lId=rs.getLong(1);
}
s="insert into T_EventBackup(id,pid,ForeignId,eventHead,eventHeadYear,eventHeadNum,secrecyLevel_code,eventType_Id,EVENTLEVEL_CODE," +
"reportDepartment,eventCaption,eventTime,eventAddress,BriefMatter,reportPerson,onDutyPerson_id," +
"signPerson_id,attachmentName,attachmentPath)"+" values("+lId+",?,?,?,?,?,?,?,?,?,?" +
",to_date(?,'YYYY-MM-DD HH24-mi-ss'),?,empty_clob(),?,?,?,?,?)"; ps=con.prepareStatement(s);
int i=1;
ps.setLong(i++, objMetaEvent.getPid());
ps.setLong(i++, objMetaEvent.getId());
ps.setString(i++, objMetaEvent.getEventHead());
ps.setLong(i++, objMetaEvent.getEventHeadYear());
ps.setLong(i++, objMetaEvent.getEventHeadNum());
ps.setString(i++, objMetaEvent.getSecrecyLevel_code());
ps.setLong(i++, objMetaEvent.getEventType_Id());
ps.setString(i++, objMetaEvent.getEventLevel_code());
ps.setString(i++, objMetaEvent.getReportDepartment());
ps.setString(i++, objMetaEvent.getEventCaption());
ps.setString(i++, objMetaEvent.getEventTime());
ps.setString(i++, objMetaEvent.getEventAddress());
ps.setString(i++, objMetaEvent.getReportPerson());
ps.setLong(i++, objMetaEvent.getOnDutyPerson_id());
ps.setLong(i++, objMetaEvent.getSignPerson_id());
ps.setString(i++, objMetaEvent.getAttachmentName());
ps.setString(i++, objMetaEvent.getAttachmentPath());
ps.executeUpdate();
//插入clob字段
rs.close();
rs=null;
ps.close();
ps=null;
s="SELECT BriefMatter FROM T_EventBackup WHERE id="+lId+"FOR UPDATE";
ps=con.prepareStatement(s);
rs=ps.executeQuery();
if(rs.next()){
Clob clobColumn=null;
clobColumn=rs.getClob(1);
DbClob.fillClob((CLOB)clobColumn, objMetaEvent.getBriefMatter());
con.commit();//执行
}
}catch(Exception e){
str=e.getMessage();
}finally{
try{if(rs!=null){rs.close();rs=null;}}catch(Exception e){str=e.getMessage();}
try{if(ps!=null){ps.close();ps=null;}}catch(Exception e){str=e.getMessage();}
try{if(con!=null){con.close();con=null;}}catch(Exception e){str=e.getMessage();}
}
return str;
}给你个例子
先获得,下个序列号,设置提交为手动提交,con.setAutoCommit(false);
插入其他非clob或者blob字段,他们(clob和Blob)用empty_clob()
然后在获得该(clob和Blob)字段,重新填充。
static public void fillClob (CLOB clob, String data) throws Exception
{
if (data == null)
{
data = "";
}
if (clob != null)
{
Writer wr = clob.getCharacterOutputStream();
wr.write(data);
wr.flush();
wr.close();
}
}
DbClob.fillClob((CLOB)clobColumn, objMetaEvent.getBriefMatter());