List:MySQL and Java« Previous MessageNext Message »
From:colbey Date:July 27 2003 7:01pm
Subject:Re: Insert Blob Example
View as plain text  
This is how I typically do it and it works well.. I store in blob
rows/sizes of 64k

// define
byte bbfull[] = new byte[65535];

// load up bbfull however you are going to (typically inputstream)
// create a prepared statement using a simple SQL insert query

// use setBytes to set the correct column and execute
ps.setBytes(2, bbfull);

On Fri, 25 Jul 2003, Rhino wrote:

> Can anyone sent me or point me to an example of a program that inserts a file like a
> JPEG or GIF into a Blob column of a MySQL table via a Java program?
> I have several years of experience with DB2 and can do this task in a Java program
> that talks to DB2 but the same program, modified to insert data into a MySQL table,
> doesn't seem to be working. There are no error messages but when I look at the table row,
> instead of a long string of hex digits, I get a few characters, like >
> Can anyone help me with a working example of inserting a Blob? That should help me
> figure out what needs to be done differently for MySQL than DB2. Or would you prefer that
> I post my code so that you can help me figure out what I'm doing incorrectly?
> Rhino
> ---
> rhino1 AT sympatico DOT ca
> "If you want the best seat in the house, you'll have to move the cat."
Insert Blob ExampleRhino26 Jul
  • RE: Insert Blob ExampleShankar Unni26 Jul
  • Re: Insert Blob Examplecolbey27 Jul
Re: Insert Blob ExampleFrank Hecker30 Jul
  • Re: Insert Blob ExampleColbey30 Jul
    • Re: Insert Blob ExampleScott Franks31 Jul
  • Re: Insert Blob ExampleRhino30 Jul
    • Re: Insert Blob ExampleDave Newton31 Jul