Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 87459 invoked from network); 19 May 2006 15:58:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 May 2006 15:58:41 -0000 Received: (qmail 22185 invoked by uid 500); 19 May 2006 15:58:40 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 22170 invoked by uid 500); 19 May 2006 15:58:40 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 22161 invoked by uid 99); 19 May 2006 15:58:39 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 May 2006 08:58:39 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [83.140.161.195] (HELO mail.fsys.se) (83.140.161.195) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 May 2006 08:58:39 -0700 Received: from [192.168.1.71] ([192.168.1.71]) by mail.fsys.se (8.13.6/8.13.4) with ESMTP id k4JGPgmC009325 for ; Fri, 19 May 2006 18:25:42 +0200 Mime-Version: 1.0 (Apple Message framework v750) Content-Transfer-Encoding: quoted-printable Message-Id: <7E627DC4-7F74-4311-8DD0-70A157BEC157@pardeike.net> Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed To: cayenne-user@incubator.apache.org From: Andreas Pardeike Subject: Inserting with a BLOB column fails Date: Fri, 19 May 2006 17:58:13 +0200 X-Mailer: Apple Mail (2.750) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlx=0 adultscore=0 adjust=0 reason=mlx engine=3.1.0-06050800 definitions=3.0.0-06051905 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, When I try to insert a new row into my image database using this code: File imgFile =3D new File(TEMPFILE2); InputStream imgStream =3D new FileInputStream(imgFile); long imgStreamLength =3D imgFile.length(); byte[] imgData =3D new byte[(int)imgStreamLength]; int offset =3D 0; int numRead =3D 0; while(offset < imgData.length && (numRead=3DimgStream.read=20 (imgData, offset, imgData.length-offset)) >=3D 0) offset +=3D numRead; imgStream.close(); Images img =3D (Images)context.createAndRegisterNewObject=20 (Images.class); img.setName("jei"); img.setGroup("medarbetare"); img.setType("image/jpeg"); img.setX(new Integer(160)); img.setY(new Integer(120)); img.setImage(imgData); context.commitChanges(); Cayenne fails with this error: QueryLogger: INSERT INTO images (group, image, name, type, x, y) =20= VALUES (?, ?, ?, ?, ?, ?) QueryLogger: [bind: 'medarbetare', < 89 50 4E 47 0D 0A 1A 0A 00 =20 00 00 0D ...>, 'jei', 'image/jpeg', 160, 120] QueryLogger: *** error. java.sql.SQLException: Syntax error or access violation message =20 from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version =20 for the right syntax to use near 'group, image, name, type, x, y) VALUES ('medarbetare', _binary'=89PNG\r\n\Z\n\0\0\' at =20= line 1" Images is defined as: CREATE TABLE `images` ( `name` varchar(64) NOT NULL default '', `group` varchar(64) NOT NULL default '', `type` varchar(64) NOT NULL default '', `image` blob NOT NULL, `x` int(11) NOT NULL default '0', `y` int(11) NOT NULL default '0', PRIMARY KEY (`name`,`group`) ) ENGINE=3DMyISAM DEFAULT CHARSET=3Dlatin1 and the relevant part in Images is: public void setImage(byte[] image) { writeProperty("image", image); } public byte[] getImage() { return (byte[])readProperty("image"); } Any pointers or ideas? I already tried changing the column type but it doesn't change anything. Andreas Pardeike