File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Any datatype to store files of size greater than 20k Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Any datatype to store files of size greater than 20k" Watch "Any datatype to store files of size greater than 20k" New topic
Author

Any datatype to store files of size greater than 20k

sowjan kumar
Greenhorn

Joined: Oct 09, 2004
Posts: 23
Hi
Iam having 2 fields in my table to store files. BLOB can insert files of size < 4k and update files of size <2k. CLOB can do both insert and update of files <4k. LONG RAW datatype is not suporting 2 fields in the same table...Any ideas as how to implement a datatype for 2 fields where i can store files of size greater than 20k will be most welcome

Sowjanya
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Which DataBase are you using? Because if it is Oracle a BLOB can store <4 Gigabytes of data, not < 4Kb. Typically too - again if you are using Oracle - you shouldn't use the LONG RAW datatype. BLOBs can store double the amount of data than LONG RAW ( <4Gb rather than < 2Gb). You can have multiple BLOBs in one table, but only one LONG RAW. Also BLOBs support random access to data whereas LONGs only support sequential access.
[ March 16, 2005: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sowjan kumar
Greenhorn

Joined: Oct 09, 2004
Posts: 23
Hello Paul,
Yeah..At last I fould a solution by having BLOB as such..As u said Iam using oracle database. The following is the code i used

insert into blob_details values(empty_blob(),empty_blob()) //initially i inserted an empty blob. No matter whether BLOB datatype in oracle is declared as NULL or NOT NULL.. we can follow this one..Then for updation of BLOB

select blob,blob_tree from blob_details where id=? for update

prepareStmt = con.prepareStatement (sql,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
.
.
.
con.setAutoCommit(false);
...
...//all necessary stream operation
...
con.commit ();//done after closing the streams...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any datatype to store files of size greater than 20k
 
Similar Threads
java.sql.Blob 4K restriction
Q about java.sql.ResultSet: how to store text in LONG column
capacity of session object
Server: Msg 511
Syntax error in INSERT INTO statement