wood burning stoves 2.0*
The moose likes JDBC and the fly likes BLOB truncated to 64MB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "BLOB truncated to 64MB" Watch "BLOB truncated to 64MB" New topic
Author

BLOB truncated to 64MB

Manzar Zaidi
Ranch Hand

Joined: Oct 21, 2004
Posts: 43
I am attempting to save a file to a mySQL db from a servlet, the issue I face is that its truncating the files to a size of 65535 bytes everytime!
The code works properly with files with smaller soze, I tested upload and download with small file sizes.
No errors show up.

The code I am using is: (Just posting the relevant portion)

try {
pstmt = dbConn.prepareStatement("INSERT INTO files VALUES( ?, ? )" ); }
catch (SQLException sqle) {System.out.println("While making prepard stat
Caught ex="+sqle);}
try{
pstmt.setString( 1, "FileName");
File imageFile = new File("pathToFileToBeUploaded.ext");
InputStream is = new FileInputStream(imageFile);
pstmt.setBinaryStream( 2, is, 999000); // Tried using different values here, no go
pstmt.executeUpdate();
uploadSucess=true;
}catch (SQLException sqle)
{System.out.println("Caught ex="+sqle);
}

Could you advise me about what what can it be ?


SCJP 1.2, SCWCD 1.4.<br />What goes around comes around ... with ver 1.1
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I guess JDBC forum would be a better place.

Anyhow, may be its mySql issue. Try Oracle or something similar(reliable and tested).
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Change the column to be MEDIUMBLOB

If you read the mysql docs BLOBs are specified to be 64k or less, MEDIUMBLOB is 2^24 bytes max (16Mb?) , LONGBLOB is 2^32 bytes max. @see http://dev.mysql.com/doc/mysql/en/storage-requirements.html

Adeel, while oracle may be reliable and tested (in your opinion, I don't have one), it generally also costs $$$, which might not be so suitable on this occasion. Mind you, LAMP style applications wouldn't be quite so popular if mysql wasn't considered reliable and tested so perhaps I do have an opinion.


I have no java certifications. This makes me a bad programmer. Ignore my post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BLOB truncated to 64MB