SCENARIO
I have the choice of manipulating database data using a byte[] or a java.sql.Blob. Which has best performance ?
java.sql.Blob
Since it does not extract any data from the database until you explicitly ask it to.
The Java platform 2 type Blob wraps a database locator (which is essentially a pointer to byte).
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 blob content.
For insertion into the database, you should use a byte[] since data has not been uploaded to the database yet.
Thus, use the Blob class only for extraction.
Conclusion : use the java.sql.Blob class for extraction whenever you can.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.