hibernate链接oracle问题求助

J2EE 码拜 9年前 (2015-04-22) 1844次浏览 0个评论

我现在再用hibernate连oracle数据库,环境是xp,jdk1.7,hibernate4,oracle10.1
现在遇到下面问题纠结了很久啊。
我的hibernate  POJO对象含有一个Blob型的属性和一个Clob型的属性。
开始使用驱动ojdbc14   出现oracle.jdbc.driver.T4CPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V
这个异常,表现问Blob插不进去,注释了Blob属性后可以正常运行
后来看见网上说是驱动不对。就换成ojdbc6,成功解决了上面问题,可以插入Blob属性,但是又出现了ORA-01461: can bind a LONG value only for insert into a LONG column异常,clob属性插不进去,又到网上去查,发现有人说是要换回ojdbc14,我有换回来试了一下,果然Clob插入成功,但是还是第一个问题Blob插入失败…………
现在我非常纠结了,有没有办法可以同时解决Blob和Clob的插入啊,跪求,等大神。 

hibernate链接oracle问题求助
10分
对应的jdbc在oracle安装目录可以找到oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar
hibernate链接oracle问题求助
引用 1 楼 a312983516 的回复:

对应的jdbc在oracle安装目录可以找到oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar

就是用得那个ojdbc14…………….那里面所有的驱动都用了 包括classes

hibernate链接oracle问题求助
引用 3 楼 fatg1988 的回复:

。。。。。。。。。。。。。。。。
别灌水啊  哥们儿。。。。。。   有解决办法没啊?

hibernate链接oracle问题求助
10分
可能是包导错误,你直接在clob或者blob类前面写上包路劲。
http://www.weste.net/2004/11-3/12250047377.html
http://blog.csdn.net/fenglibing/article/details/669476
hibernate链接oracle问题求助
引用 5 楼 peng_hao1988 的回复:

可能是包导错误,你直接在clob或者blob类前面写上包路劲。
http://www.weste.net/2004/11-3/12250047377.html
http://blog.csdn.net/fenglibing/article/details/669476

你给我的方法都是先存空的再往里存,我想直接用hibernate自带的面向对象的存储方式。而且我只要换驱动就有一个能成功运行……….   不会是代码的问题吧0.0      

hibernate链接oracle问题求助
10分
关注,
ORA-01461: can bind a LONG value only for insert into a LONG column
我怎么看这个异常提示都和clob无关呢
hibernate链接oracle问题求助
引用 7 楼 dracularking 的回复:

关注,
ORA-01461: can bind a LONG value only for insert into a LONG column
我怎么看这个异常提示都和clob无关呢

对   异常提示其实跟Clob无关,但是只要换过驱动就不会报错,长字段也可以插入。。。。说明是驱动的问题啊………..

hibernate链接oracle问题求助
60分
引用 8 楼 nklnklnklnkl 的回复:

对   异常提示其实跟Clob无关,但是只要换过驱动就不会报错,长字段也可以插入。。。。说明是驱动的问题啊………..

我只是试图从这种现象分析入手

先看下oracle关于ORA-01461的解释:

 The Oracle docs note this on the ORA-01461 error:

ORA-01461 can bind a LONG value only for insert into a LONG column
 
    Cause: An attempt was made to insert a value from a LONG datatype into another datatype. This is not allowed.
     
    Action: Do not try to insert LONG datatypes into other types of columns.

Answer:  The LONG and LONG RAW datatypes have been deprecated and the easiest solution to the ORA-01461 error is to change the column datatype to as CLOB.

The replier suggested that instead of using LONG as the column, that ORA-01461 could be avoided if the binary stream was LONG RAW instead.  

出现这种异常是因为将LONG的数据类型插入非LONG型列中,但你是在插clob数据,怎么会报这提示呢,后来了解到可能oracle把clob数据也作为异常报告中的long型数据对待了(clob属于LOB)

when you configure the Oracle ODBC Driver you must check the Enable LOBs option (this is in the Oracle tab at the bottom). If you don””t do this you will be unable to insert LOB values, instead you will get the message: “ORA-01461: can bind a LONG value only for insert into a LONG column”

oracle的Enable LOBs有没有选上?

hibernate链接oracle问题求助
引用 10 楼 dracularking 的回复:
Quote: 引用 8 楼 nklnklnklnkl 的回复:

对   异常提示其实跟Clob无关,但是只要换过驱动就不会报错,长字段也可以插入。。。。说明是驱动的问题啊………..

我只是试图从这种现象分析入手

先看下oracle关于ORA-01461的解释:

 The Oracle docs note this on the ORA-01461 error:

ORA-01461 can bind a LONG value only for insert into a LONG column
 
    Cause: An attempt was made to insert a value from a LONG datatype into another datatype. This is not allowed.
     
    Action: Do not try to insert LONG datatypes into other types of columns.

Answer:  The LONG and LONG RAW datatypes have been deprecated and the easiest solution to the ORA-01461 error is to change the column datatype to as CLOB.

The replier suggested that instead of using LONG as the column, that ORA-01461 could be avoided if the binary stream was LONG RAW instead.  

出现这种异常是因为将LONG的数据类型插入非LONG型列中,但你是在插clob数据,怎么会报这提示呢,后来了解到可能oracle把clob数据也作为异常报告中的long型数据对待了(clob属于LOB)

when you configure the Oracle ODBC Driver you must check the Enable LOBs option (this is in the Oracle tab at the bottom). If you don””t do this you will be unable to insert LOB values, instead you will get the message: “ORA-01461: can bind a LONG value only for insert into a LONG column”

oracle的Enable LOBs有没有选上?

好的 非常感谢你的回复哈  我过了五一去机房试试  哈哈

hibernate链接oracle问题求助
http://bbs.csdn.net/topics/390823691
看看这个行不行

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明hibernate链接oracle问题求助
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!