List:MySQL and Java« Previous MessageNext Message »
From:Christian Mack Date:February 11 2000 7:03am
Subject:Re: Inserting Blobs
View as plain text  
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
Thread
client server applicationAhmed K Bayyari4 Feb
  • Re: client server applicationJohn Raab4 Feb
  • RE: client server applicationRoy Nasser4 Feb
RE: client server applicationAhmed K Bayyari4 Feb
RE: client server applicationRichard Schilling8 Feb
  • Inserting BlobsCalistra Research Labs8 Feb
    • Re: Inserting BlobsChristian Mack11 Feb
    • Re: Inserting BlobsMark Matthews11 Feb
      • RE: Inserting Blobs(John Zollinger)11 Feb
        • Copy table structure?CLAUDE LEBLANC11 Feb
          • Re: Copy table structure?CLAUDE LEBLANC12 Feb
        • RE: Inserting BlobsMark Matthews12 Feb
        • Server configuration denies access to data source?(John Zollinger)18 Feb
          • Re: Server configuration denies access to data source?Roland Becker18 Feb
    • Re: Inserting BlobsCris Perdue11 Feb
RE: client server applicationCarlos Proal8 Feb