6 messages in com.mysql.lists.javaRE: PreparedStatement and blobs
FromSent OnAttachments
Luca Lafranchi14 Nov 2002 05:31 
Jon Frisby14 Nov 2002 10:01 
Jon Frisby14 Nov 2002 15:23 
David Tonhofer, m-plify S.A.14 Nov 2002 15:41 
Jon Frisby14 Nov 2002 16:01 
Mark Matthews15 Nov 2002 13:42 
Subject:RE: PreparedStatement and blobs
From:Jon Frisby (jfri@yfdirect.com)
Date:11/14/2002 10:01:20 AM
List:com.mysql.lists.java

Are you using a BLOB column? A BLOB is limited to 2^16 bytes (64KB). Try using a MEDIUMBLOB (2^24 bytes - 16MB) or a LONGBLOB (2^32 bytes - 4GB) instead.

-JF

-----Original Message----- From: Luca Lafranchi [mailto:luca@rohag.ch] Sent: Thursday, November 14, 2002 5:32 AM To: ja@lists.mysql.com Subject: PreparedStatement and blobs

Hi :)

I'm trying to import some jpg's into mysql 3.23.51 max-nt using the connector/J driver. Here's a sample code:

Assume my picture is in a byte[] array "pic". Autocommit is ON.

PreparedStatement pstmt = connection.prepareStatement("insert into blabla...");

ByteArrayInputStream bais = new ByteArrayInputStream(pic); pstmt.setBinaryStream(index,bais,pic.length); pstmt.executeUpdate(); pstmt.close();

This code works, but with big pictures I have problems: the bytes aren't fully written, so when I try to show the imported images, they appear corrupted. I've tried the 2.0.14 as well as the 3.0.2beta version, and this happens in both of them... I also tried using "pstmt.setBytes(index,pic)" with the same result.

The code above works perfectly with MS Access.

Has anybody a clue??

To request this thread, e-mail <java@lists.mysql.com> To unsubscribe, e-mail <java-unsubscribe-jfrisby=your@lists.mysql.com>