I have the choice of manipulating database data using a String or a java.sql.Clob. Which has best performance ?
java.sql.Clob
Since, it does not extract any data from the database until you explicitly ask it to.
The Java platform 2 type Clob wraps a database locator (which is essentially a pointer to char).
That pointer is a rather large number (between 32 and 256 bits in size) - but the effort to extract it from the database is insignificant next to extracting the full Clob content.
For insertion into the database, you should use a String since data need not been downloaded from the database.
Thus, use the Clob class only for extraction.
Conclusion : Unless you always intend to extract the full textual data stored in the particular table cell, use the java.sql.Clob class for extraction whenever you can.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.