I have successfully converted an image into a byte array which i am then trying to store in an MS Access database in an OLE Object Field.
I am using a statement.executeUpdate SQL statement to insert my data along with teh byte array into the database. I do not know if this is the correct way of doing it, but i cannot find any helpful examples or documentation for my problem.
It keeps returning the error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Missing ), ], or Item in query expression '[B@1667df0)'
My code is below:
Thanks in advance for any help!
[added line breaks so screen doesn't scroll right] [ March 31, 2007: Message edited by: Jeanne Boyarsky ]
The only problem i am having now is when i retrieve the byte array from access and pass it into an ImageIcon i get a null pointer exception. I have output the contents of the array and it has been populated with data.
Thanks once again!
Joined: Dec 30, 2002
I have successfully placed an image into MS Access with Jeanne's kind help, but i am having problems getting it back out again.
Is this something anybody can help me with? The code i am using is below.
Emile, Now you're one step closer to having a solution!
Two things to confirm: 1) Is the byte null before you set it? Can you build an ImageIcon out of it before it goes into the database? 2) If the byte null after you get it back? ImageIcon could be throwing a null pointer because the bytes are null or because they don't form a valid image.
I recommend troubleshooting this by using a simpler string. For example "hello world".getBytes(). That way you can do new String(bytes) on what you get back to make sure it is the same.
Joined: Dec 30, 2002
I can build the ImageIcon before it goes to the database and i can successfully write the image to a file from Access using a FIleOutputStream, to confirm it is stored correctly.
When i print the byte array it seems to be filled with random numbers so i am assuming that it contains the correct contents. This is something that really has me puzzled.
Is the code i posted the right way to go about retrieving the bytes from Access and converting them to an ImageIcon?