Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Blob字段处理 #260

Closed
aodixiaoqiang opened this Issue · 12 comments

4 participants

@aodixiaoqiang

Blob类型的字段,对应的Pojo属性应该设置成什么类型啊?InputStream? byte[]? Blob?
入口函数怎么获取和操作表单提交过来的二进制数据啊(一个文本控件中的内容)?

@wendal
Owner

InputStream

@aodixiaoqiang

入口函数中直接对属性进行setXXX(InputStream xxx) ,然后插入会报错:“无效的十六进制”。还是要自己对流进行处理?

@wendal
Owner

贴代码及出错信息

@aodixiaoqiang

Pojo:
@Table("XXX")
public class Pojo{
@Id(auto=false)
@Prev(@SQL("select max(pkid+1) from XXX"))
@Column("pkid")
private int id;

@Column
private String name;

@Column
private InputStream content;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public InputStream getContent() {
return content;
}

public void setContent(InputStream content) {
this.content = content;
}

}

表单:

这里是一个word控件

入口函数:
@At
@AdaptBy(type=VoidAdaptor.class)
@Ok("void")
public void XXX(HttpServletRequest req){
//Pojo对象
Pojo pojo = new Pojo();
DiskFileItemFactory fac = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(fac);
List fileList = null;
try {
fileList = upload.parseRequest(req);
} catch (FileUploadException ex) {
return;
}
Iterator it = fileList.iterator();
//表单字段名称
String fieldName = "";
while (it.hasNext()) {
FileItem item = it.next();
fieldName = item.getFieldName();
if("name".equals(fieldName)){
//名称
pojo.setName(item.getString().trim());
}else if("doc".equals(fieldName)){
//模板内容(blob)
pojo.setContent(item.getInputStream());
}
}
dao.insert(pojo);

出错信息:
DEBUG http-8089-Processor18 - select max(pkid+1) from XXX
DEBUG http-8089-Processor18 - INSERT INTO XXX(pkid,name,content) VALUES(?,?,?)
| 1 | 2 | 3 |

|-----|-----|---------------------------------|
| 11 | 名称 | java.io.FileInputStream@1c674df
For example:> "INSERT INTO XXX(pkid,name,content) VALUES(11,'名称','java.io.FileInputStream@1c674df') "
DEBUG http-8089-Processor18 - SQLException
java.sql.SQLException: ORA-01465: 无效的十六进制数字

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:179)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:139)
at org.nutz.dao.impl.DaoSupport$2.invoke(DaoSupport.java:188)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:30)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:180)
at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
at org.nutz.dao.impl.NutDao.insert(NutDao.java:110)
at com.hzwj.common.dao.DaoOperator.insertObj(DaoOperator.java:75)
at com.hzwj.common.dao.DaoOperator$$NUTZAOP._aop_invoke(Unknown Source)
at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:76)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:56)
at org.nutz.aop.interceptor.TransactionInterceptor$1.run(TransactionInterceptor.java:37)
at org.nutz.trans.Trans.exec(Trans.java:123)
at org.nutz.aop.interceptor.TransactionInterceptor.filter(TransactionInterceptor.java:34)
at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:59)
at com.hzwj.common.dao.DaoOperator$$NUTZAOP.insertObj(Unknown Source)
at com.hzwj.modules.jgjz.system.RecordTemplate.saveTemplate(RecordTemplate.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:22)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:42)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:83)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:36)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
@wendal
Owner

你用的是老版本的nutz??

@aodixiaoqiang

1.b.43

@ok
ok commented

How do I get out of here? I get regular notification about activities in this project, which I'm part of by accident.

Thanks,
Oliver

@wendal
Owner

@ok , click "Unwatch"

@wendal
Owner

@aodixiaoqiang 上QQ聊一下吧

@wendal
Owner

fixed

@wendal wendal closed this
@wendal wendal was assigned
@ruke

1.b.34版本支持clob字段类型处理不?

@wendal
Owner

不支持

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.