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, 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.