Redian新闻
>
使用Clob的setString方法出现如下错误
avatar
使用Clob的setString方法出现如下错误# Java - 爪哇娇娃
m*o
1
【 以下文字转载自 Military 讨论区 】
发信人: mingo (豺狼虎豹四不象), 信区: Military
标 题: 你们的政治觉悟太低了
发信站: BBS 未名空间站 (Wed Nov 3 21:56:13 2010, 美东)
来看看祖国的下一代
avatar
t*k
2
Clob clob = null;
String strTemp;
... //给strTemp赋了一文章的内容
clob.setString(1,strTemp)
执行到上面一句是出现如下错误
用的系统是Oracle9i
看了JDK,setString在1.4已经支持了
而我用的Bea Weblogic 8.1
用的是JDK1.4.1
为什么?
java.sql.SQLException: 不支持的特性
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.dbaccess.DBError.throwUnsupportedFeatureSqlException(DBEr
ror.java:690)
at o
avatar
m*t
3

Which version of the jdbc driver are you using? Did you try setClob()?

【在 t********k 的大作中提到】
: Clob clob = null;
: String strTemp;
: ... //给strTemp赋了一文章的内容
: clob.setString(1,strTemp)
: 执行到上面一句是出现如下错误
: 用的系统是Oracle9i
: 看了JDK,setString在1.4已经支持了
: 而我用的Bea Weblogic 8.1
: 用的是JDK1.4.1
: 为什么?

avatar
m*t
4

I'm sorry, I didn't realize you were using Clob.setString() already.
Never mind the second question.
I remember Oracle has some weird way of handling clobs and blobs. Last time I
had to do this, I had to downcast the drive to the oracle driver class and
call some proprietary methods on it. And that was around JDK 1.3.1 or so...

【在 m******t 的大作中提到】
:
: Which version of the jdbc driver are you using? Did you try setClob()?

avatar
t*k
5
是先处理clob,用setString把String变量的值放到
clob里
然后用setClob
因为把所一文章里的文字放到clob字段内

【在 m******t 的大作中提到】
:
: I'm sorry, I didn't realize you were using Clob.setString() already.
: Never mind the second question.
: I remember Oracle has some weird way of handling clobs and blobs. Last time I
: had to do this, I had to downcast the drive to the oracle driver class and
: call some proprietary methods on it. And that was around JDK 1.3.1 or so...

avatar
t*k
6
实际上我曾试过oralce.sql.CLOB
但一用这,我连从数据库中取clob字段的值都出错
就是下面语句
oralce.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(1)
一执行到这
后面的语句都不执行了
没抛出异常
却去执行finally里的语句了
真是不懂
用下面的没事
Clob clob = rs.getClob(1)
另外我的同事用oracle.sql.CLOB没事
我的语句和他的没什么两样
Faint死我了

【在 m******t 的大作中提到】
:
: I'm sorry, I didn't realize you were using Clob.setString() already.
: Never mind the second question.
: I remember Oracle has some weird way of handling clobs and blobs. Last time I
: had to do this, I had to downcast the drive to the oracle driver class and
: call some proprietary methods on it. And that was around JDK 1.3.1 or so...

avatar
xt
7

This is probably the problem of Oracle JDBC itself. As I remember
if they string is too long (sth like more than 2 or 4k), you may
not use setString directly with Oracle thin driver.
This is one of the reasons why Oracle JDBC sucks

【在 m******t 的大作中提到】
:
: I'm sorry, I didn't realize you were using Clob.setString() already.
: Never mind the second question.
: I remember Oracle has some weird way of handling clobs and blobs. Last time I
: had to do this, I had to downcast the drive to the oracle driver class and
: call some proprietary methods on it. And that was around JDK 1.3.1 or so...

avatar
w*t
8

yea, it sucks. let me add 2nd reason,
some API methods were never "really" implemented.

【在 xt 的大作中提到】
:
: This is probably the problem of Oracle JDBC itself. As I remember
: if they string is too long (sth like more than 2 or 4k), you may
: not use setString directly with Oracle thin driver.
: This is one of the reasons why Oracle JDBC sucks

avatar
m*t
9

I googled "oracle clob". There seems to be a lot of discussion (or whining if
you will) about it. You might want to check it out.

【在 t********k 的大作中提到】
: 是先处理clob,用setString把String变量的值放到
: clob里
: 然后用setClob
: 因为把所一文章里的文字放到clob字段内

avatar
xt
10

if
Oracle JDBC driver, especially the Oracle:thin driver, is the worst I know
amoungst
major DBMS's. It has many many problems. For example, if you define a CHAR[40]
field
in your schema, then set it to "hello". It works fine if you do a direct SQL
search
for WHERE field='hello'. However if you use JDBC with the very same string,
you will
never get the record back. You have to use "hello" padded with 34 spaces to
get the
record back. Talking about consistency! IMHO, Sybase has the best SQL
comp

【在 m******t 的大作中提到】
:
: I googled "oracle clob". There seems to be a lot of discussion (or whining if
: you will) about it. You might want to check it out.

avatar
m*c
11

The Oracle 9i JDBC driver for JDK 1.4 is no longer "classes12.zip", it is
another one (you can find it in the same directory where "classes12.zip" can
be found inside Oracle installation directory).
Our product doesn't use JDK 1.4 yet, so we had to use "oracle.sql.CLOB"
object. Basically, you use "empty_clob()" first to do insert and then use
"select ... from ... where ... for update" and then retrieve CLOB data (should
be empty for the first time) and update it ("getCharacterOutputStream" met

【在 t********k 的大作中提到】
: 实际上我曾试过oralce.sql.CLOB
: 但一用这,我连从数据库中取clob字段的值都出错
: 就是下面语句
: oralce.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(1)
: 一执行到这
: 后面的语句都不执行了
: 没抛出异常
: 却去执行finally里的语句了
: 真是不懂
: 用下面的没事

avatar
xt
12

Yes, this is the way we do the job. MS SQL Server has some other
JDBC problems such as stored procedure support etc. The SQL itself
is very similar to Sybase because MS bought their source code.

【在 m**c 的大作中提到】
:
: The Oracle 9i JDBC driver for JDK 1.4 is no longer "classes12.zip", it is
: another one (you can find it in the same directory where "classes12.zip" can
: be found inside Oracle installation directory).
: Our product doesn't use JDK 1.4 yet, so we had to use "oracle.sql.CLOB"
: object. Basically, you use "empty_clob()" first to do insert and then use
: "select ... from ... where ... for update" and then retrieve CLOB data (should
: be empty for the first time) and update it ("getCharacterOutputStream" met

avatar
m*c
13

We are using Opt2000 JDBC driver for MS SQL, it is very good.
(should
method
We

【在 xt 的大作中提到】
:
: Yes, this is the way we do the job. MS SQL Server has some other
: JDBC problems such as stored procedure support etc. The SQL itself
: is very similar to Sybase because MS bought their source code.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。