Calistra Research Labs wrote:
>
> I am using the following code to try to insert images of over 70K- but the code dies
> on the
> update command. It dies either with the commented code (setBytes) or the uncommented
> code
> (setBinaryStream)
>
> pStmt = new org.gjt.mm.mysql.PreparedStatement( Conn, "update pictures set
> image_data=? where id=?","");
>
> picFile = new File("d:\\catalog\\" + image_filename);
> picFileLength = picFile.length();
> label_1.setText( "transfer file to DB "+picFileLength);
> picFileStream = new FileInputStream( picFile );
> /*
> picArray = new byte[ (int)picFileLength ];
> result = picFileStream.read( picArray, 0, (int)picFileLength );
> picFileStream.close();
> pStmt.setBytes(1,picArray);
> */
> pStmt.setBinaryStream(1,picFileStream,(int)picFileLength);
> pStmt.setInt(2,id);
> pStmt.executeUpdate();
>
> Debug log connecting to localhost:7777
> java.lang.ArrayIndexOutOfBoundsException
> at org.gjt.mm.mysql.Buffer.writeBytesNoNull(Buffer.java:352)
> at
> org.gjt.mm.mysql.PreparedStatement.executeUpdate(PreparedStatement.java:291)
> at MainForm.MainForm_objectCreated(MainForm.java:341)
> at MainForm.create(MainForm.java:196)
> at PortfolioMySQL.createAppletForm(PortfolioMySQL.java:24)
> at PortfolioMySQL.init(PortfolioMySQL.java:19)
> at sun.applet.AppletPanel.run(AppletPanel.java:286)
> at java.lang.Thread.run(Thread.java:466)
> Dave Appleton Calistra Research Labs Pte Ltd
Hi Dave
1) you should use :
pStmt.setMaxFieldSize( int );
to increase the maximum Field size.
Most drivers use an initial size of 64kBytes.
2) The mm driver (at least version <= 1.2b) has a limit of 64Kbytes on uploads.
This is a known bug. You can increase the write buffer manually.
But this requires recompilation of mm driver, and it isn't a really solution.
twz driver works OK.
Tschau
Christian