Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2007

Tip: Looking for answers? Try searching our database.

CLOB issue with JDBC, IBATIS and Oracle 10g

Thread view: 
kartechy@googlemail.com - 21 Sep 2007 11:50 GMT
Hi,

I have some JAVA code to make connection and insert some data into
Oracle 10g via Ibatis framework, its failing for CLOB data type,  Can
you please help me to resolve this ?

see the JAVA code flow below

FileA.java
-------------

SqlMapClient sqlMap = SQLConfig.getSqlMapInstance(); // this sqlconfig
xml contains all the login details..
sqlMap.StartTransaction();
FileB_Object.setExampleText(myStringBuffer.toString());   // this file
contains get/set methods
sqlMap.insert("insertExampleText", FileB_Object);
sqlMap.CommitTransaction();

FileB.java
-----------------
   private String exampleText;
   public String  getExampleText() {
       return exampleText;
   }

   public void setExampleText(String   exampleText) {
    this.exampleText =exampleText;
   }
FileC.XML
----------------
which contains all the SQLs , Properties , reference to FileB.Class -
part of IBatis and I added the following line also.
<result property="exampleText" column="exampleText" jdbcType="BLOB"/>

The same code is working fine if the length is less than 4000 and
failed for more than 4000  chars

I am getting this error

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in c:\temp\FileC.xml.
--- The error occurred while applying a parameter map.
--- Check the insertExampleText-InlineParameterMap.
--- Check the parameter mapping for the 'exampleText' property.
--- Cause: java.sql.SQLException: Data size bigger than max size for
this type: 7821
Caused by: java.sql.SQLException: Data size bigger than max size for
this type: 7821

After this error I tried to change the "exampleText" as java.sql.CLOB
in all the places - but its again failed and getting the same error

Any help would be great

Thanks

Kart.
RedGrittyBrick - 21 Sep 2007 12:07 GMT
> Hi,
>
> I have some JAVA code to make connection and insert some data into
> Oracle 10g via Ibatis framework, its failing for CLOB data type,  Can
> you please help me to resolve this ?

Multiposted
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
Roedy Green - 22 Sep 2007 04:14 GMT
>The same code is working fine if the length is less than 4000 and
>failed for more than 4000  chars
>--- Cause: java.sql.SQLException: Data size bigger than max size for
>this type: 7821

Recall a char is 2 bytes.  So it seems the limit is 7821 chars or 3910
chars for that particular type.  See what other types are available.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 22 Sep 2007 14:57 GMT
>> The same code is working fine if the length is less than 4000 and
>> failed for more than 4000  chars
[quoted text clipped - 3 lines]
> Recall a char is 2 bytes.  So it seems the limit is 7821 chars or 3910
>  chars for that particular type.  See what other types are available.

Small nit: the number of bytes per char is variable, depending on the
database's encoding.

The OP showed various definitions on the Java side, trying to coerce the data
variously into a Java BLOB or CLOB type.  They didn't show the Oracle column
definition for the column in question.  Yet another case of the information
that contains the key to the answer having been omitted from the question.

Clearly the column must be VARCHAR2:
> VARCHAR2(size [BYTE | CHAR])
>
> Variable-length character string having maximum length size bytes or characters.
> Maximum size is 4000 bytes or characters, and minimum is 1 byte or 1 character.

Here's the secret, OP - the JDBC type has to match the column type.  Just
calling it a BLOB or a CLOB (and there is a difference between those two!) to
Java doesn't make it so to the database.

Signature

Lew

Roedy Green - 22 Sep 2007 22:42 GMT
>Small nit: the number of bytes per char is variable, depending on the
>database's encoding.

In a pathological case UTF-8 can take 3 bytes per char.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

David Harper - 23 Sep 2007 09:08 GMT
>> Small nit: the number of bytes per char is variable, depending on the
>> database's encoding.
>
> In a pathological case UTF-8 can take 3 bytes per char.

By "pathological case", you presumably mean "most of the languages of
east Asia, including India and China, the two most populous nations on
Earth"? ;-)

David Harper
Cambridge, England
John W. Kennedy - 23 Sep 2007 19:10 GMT
>>> Small nit: the number of bytes per char is variable, depending on the
>>> database's encoding.
[quoted text clipped - 4 lines]
> east Asia, including India and China, the two most populous nations on
> Earth"? ;-)

They're pathological for UTF-8.

Signature

John W. Kennedy
"The bright critics assembled in this volume will doubtless show, in
their sophisticated and ingenious new ways, that, just as /Pooh/ is
suffused with humanism, our humanism itself, at this late date, has
become full of /Pooh./"
  -- Frederick Crews.  "Postmodern Pooh", Preface

Roedy Green - 24 Sep 2007 01:33 GMT
On Sun, 23 Sep 2007 08:08:47 GMT, David Harper
<devnull@obliquity.u-net.com> wrote, quoted or indirectly quoted
someone who said :

>By "pathological case", you presumably mean "most of the languages of
>east Asia, including India and China, the two most populous nations on
>Earth"? ;-)

When I wrote that I was thinking more in terms of rows of dingbats
\u27xx
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

RedGrittyBrick - 24 Sep 2007 15:20 GMT
>> Small nit: the number of bytes per char is variable, depending on
>> the database's encoding.
>
> In a pathological case UTF-8 can take 3 bytes per char.

UTF-8 takes *four* octets for a code point outside Unicode's base plane.
For example the cuneiform numeric sign three sharu (U+1242E) is
F0 92 90 AE
David Harper - 24 Sep 2007 19:32 GMT
>>> Small nit: the number of bytes per char is variable, depending on
>>> the database's encoding.
[quoted text clipped - 4 lines]
> For example the cuneiform numeric sign three sharu (U+1242E) is
> F0 92 90 AE

How wonderfully ironic that there's a Unicode block (and a UTF-8
encoding!) devoted to the cuneiform script, a data storage format that
remains readable almost five thousand years after it was invented.

How many of our databases will still be readable in 7000 AD?

Thanks for sharing that.  It made my day :-)

David Harper
Cambridge, England


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.