Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 5th, 2007, 03:24 PM
Registered User
Join Date: Nov 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing data in a varbinary field in SQL

I'm new to Java. I'm trying to update a byte array (byte[]) field in java into a Varbinary column in SQL.

byte[] xxx ... statement returns a value of B@1d7ad1c

MyString = "INSERT INTO MyTable " +
   "VALUES ('" + name + "'," + xxx + ",'test')";

I get the following error:
SQLException: Unclosed quotation mark before the character string 'B@1d7ad1c,'test')'.

How do I update the byte[] field into a varbinary column in sql.

Thanks in advance for your help.

Old February 6th, 2007, 10:27 AM
Friend of Wrox
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts

Does putting quotes round your byte array help?
"VALUES ('" + name + "','" + xxx + "','test')";

Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Old February 9th, 2007, 08:03 AM
Authorized User
Join Date: Sep 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts

Try following change

"VALUES ('" + name + "','" + xxx + "','" + test + "')";

Similar Threads
Thread Thread Starter Forum Replies Last Post
storing field values to variables imaginevictor SQL Server 2000 1 July 3rd, 2007 02:17 AM
Storing data to a variable Mikect VB Databases Basics 1 April 16th, 2007 01:53 PM
Inserting data into an Access memo field with SQL jhunta VB How-To 3 September 20th, 2005 02:49 PM
Storing complete table rows in a single field KenNeedham Oracle 2 January 22nd, 2004 01:45 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.