Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 5th, 2007, 03:24 PM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing data in a varbinary field in SQL

Hi,
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.

Reply With Quote
  #2 (permalink)  
Old February 6th, 2007, 10:27 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
  #3 (permalink)  
Old February 9th, 2007, 08:03 AM
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2006
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try following change

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



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:20 PM.


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