commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knezevic, Mihael" <m.kneze...@porta.de>
Subject RE: [fileupload] Maximum size for upload?
Date Thu, 28 Jul 2005 07:37:03 GMT
java docs (1.5):

<quote>
setBytes:

Sets the designated parameter to the given Java array of bytes. The driver converts this to
an SQL VARBINARY or LONGVARBINARY  (depending on the argument's size relative to the driver's
limits on VARBINARY values) when it sends it to the database. 
</quote>

perhaps you should try to use a blob object and use setBlob. perhaps the SerialBlob class
helps. i got no experience with blobs so this is just a suggestion which doesn't have to work.


> -----Original Message-----
> From: Martin Grogan [mailto:mgrogan@mobilegolfers.net] 
> Sent: Thursday, July 28, 2005 9:10 AM
> To: Jakarta Commons Users List
> Subject: Re: [fileupload] Maximum size for upload?
> 
> Hi Mihael,
> I've checked the size of the array, it is 89K, which is about 
> right. It 
> is also definately being placed into a MEDIUMBLOB which I 
> think is 2^24 
> bytes max. There shouldn't be a problem there.
> I'm wondering if it's a problem with setting the stream for the 
> preparedStatement, i.e.
>     
> //statement.setBinaryStream(1,inStream2,orig.length);         
>                
> // setBinaryStream no good ??
>      statement.setBytes(1,orig);
> Thanks,
> Martin
> 
> 
> Knezevic, Mihael wrote:
> 
> >i definitly uploaded a file of more than 40mb via the 
> fileupload lib. so the size shouldn't be the problem.
> >
> >first i would check the length of the array orig after the 
> following line:
> >byte[] orig= os2.toByteArray();
> >
> >then if would double check the definition of the columns in 
> the table.
> >
> >good luck.
> >
> >mk
> >
> >  
> >
> >>-----Original Message-----
> >>From: Martin Grogan [mailto:mgrogan@mobilegolfers.net] 
> >>Sent: Thursday, July 28, 2005 8:49 AM
> >>To: Jakarta Commons Users List; mgrogan@mobilegolfers.net
> >>Subject: [fileupload] Maximum size for upload?
> >>
> >>Hi all,
> >>Some time ago, I posted a question (and subsequently a code 
> solution) 
> >>relating to JPEG scaling. This issue has now been resolved, 
> and I am 
> >>working on storing images uploaded to a mySQL database as BLOBs 
> >>(MEDIUMBLOB).
> >>It seems that when the image size is > 65535 bytes, the 
> bottom of the 
> >>image is chopped off, and I am left with an image that is 
> >>exactly 65535 
> >>bytes.
> >>If anyone has any ideas on why this might be happening, and 
> how I can 
> >>resolve it, I would be grateful.
> >>Many thanks,
> >>Martin
> >>
> >>Some of the code I'm using is here...
> >>      
> >>                    ..............................
> >>                    BufferedImage origImage = new 
> >>BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
> >>                     java.awt.Graphics2D graphics2D2 = 
> >>origImage.createGraphics();                                   
> >>         
> >>                    
> >>graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
> >>POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
> >>                   graphics2D2.drawImage(image, 0, 0, imageWidth, 
> >>imageHeight, null);
> >>                    // get output stream from image         
>          
> >>                    ByteArrayOutputStream os2= new 
> >>ByteArrayOutputStream();
> >>                    ImageIO.write(origImage,"jpeg",os2);      
> >>            
> >>                    byte[] orig= os2.toByteArray();
> >>                    // setup input stream for blob          
>          
> >>                    ByteArrayInputStream inStream2= new 
> >>ByteArrayInputStream(orig);
> >>                    try
> >>                    {
> >>                        Class.forName( "com.mysql.jdbc.Driver");
> >>                        Connection 
> >>connection=DriverManager.getConnection("jdbc:mysql://localhost
> >>/gallery","gallery","gallery");    
> >>       
> >>                        String query="INSERT INTO img (name, 
> >>pic) VALUES 
> >>('";                       
> >>                        query=query+"picture',";
> >>                        query=query+"?"+")";
> >>                        PreparedStatement statement = 
> >>connection.prepareStatement(query);                        
> >>                      
> >>                        
> >>//statement.setBinaryStream(1,inStream2,orig.length);         
> >>               
> >>// doesn't seem to work either
> >>                        statement.setBytes(1,orig);
> >>                        ....................
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: 
> commons-user-help@jakarta.apache.org
> >>
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> >
> >  
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message