lixuemao 2015-12-08 07:14 采纳率: 0%
浏览 12721

java 如何保存、读取数据库字段为blob类型的值

java 如何保存、读取javaBean中定义String类型,oracle数据库字段为blob类型的值

这是我的业务逻辑代码
try {
String encoding = "GBK";
File file = new File("E:\workspaceNeuSoft\tomcat7.0.40\logs\localhost.2015-12-07.log");
if (file.isFile() && file.exists()) { // 判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), encoding);// 考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
// System.out.println(lineTxt);
interfaceLog.setFwqIp(ip);
interfaceLog.setJkLog(lineTxt);
interfaceLogService.createInterfaceLog(interfaceLog);
}
read.close();
} else {
System.out.println("找不到指定的文件");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
}

这个是mybatis中代码


SELECT seq_neu_interfacelog_id.NEXTVAL FROM DUAL


<![CDATA[
INSERT INTO neu_interfacelog DS
(DS.ROW_ID,
DS.CREATE_BY,
DS.CREATE_DATE,
DS.REMARK,
DS.FWQ_IP,
DS.INTERFACELOG
)
VALUES
(#{rowId},
#{createBy},
SYSDATE,
#{remark},
#{fwqIp},
#{jkLog})

    ]]> 
</insert>


现在控制台报异常
015-12-08 15:00:00,620 INFO  org.quartz.plugins.history.LoggingTriggerHistoryPlugin.triggerComplete:432 - Trigger neuSoftWorkPlatform_TRIGGER_GROUP.interfaceLogExpireBean completed firing job neuSoftWorkPlatform_JOB_GROUP.interfaceLogExpire at  15:00:00 12/08/2015 with resulting trigger instruction code: DO NOTHING

org.springframework.jdbc.UncategorizedSQLException:

Error updating database. Cause: java.sql.SQLException: ORA-01465: 无效的十六进制数字

The error may exist in file [E:\workspaceNeuSoft\neuSoftWorkPlatform\neuSoftWorkPlatform-biz\target\classes\mybatis\mappers\interfaceLog\InterfaceLogMapper.xml]

The error may involve com.neusoft.interfaceLog.dao.InterfaceLogDAO.save-Inline

The error occurred while setting parameters

SQL: INSERT INTO neu_interfacelog DS (DS.ROW_ID, DS.CREATE_BY, DS.CREATE_DATE, DS.REMARK, DS.FWQ_IP, DS.INTERFACELOG ) VALUES (?, ?, SYSDATE, ?, ?, ?)

Cause: java.sql.SQLException: ORA-01465: 无效的十六进制数字

; uncategorized SQLException for SQL []; SQL state [72000]; error code [1465]; ORA-01465: 无效的十六进制数字
; nested exception is java.sql.SQLException: ORA-01465: 无效的十六进制数字

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy27.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:79)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
at com.sun.proxy.$Proxy86.save(Unknown Source)
at com.neusoft.interfaceLog.service.impl.InterfaceLogServiceImpl.createInterfaceLog(InterfaceLogServiceImpl.java:60)
at com.haier.openplatform.showcase.quartz.InterfaceLogExpireJob.execute(InterfaceLogExpireJob.java:52)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)

Caused by: 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:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
at com.haier.openplatform.jdbc.HOPPraparedStatement$3.run(HOPPraparedStatement.java:183)
at com.haier.openplatform.jdbc.HOPPraparedStatement$3.run(HOPPraparedStatement.java:180)
at com.haier.openplatform.jdbc.HOPPraparedStatement.doProfile(HOPPraparedStatement.java:382)
at com.haier.openplatform.jdbc.HOPPraparedStatement.execute(HOPPraparedStatement.java:180)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
... 9 more
  • 写回答

3条回答 默认 最新

  • sole.mjc 2018-06-22 02:30
    关注

    java中如何接收一个 十六进制的数据 并保存到数据库中,数据库中字段类型longbolb,如何读取

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?