Solved

com.sybase.jdbc2.jdbc.SybSQLException: ERROR=Parse failure - Only hard-coded values are getting inserted into the database from application

Posted on 2009-04-04
3
589 Views
Last Modified: 2012-05-06
I am trying to execute a simple query which updates value in a sybase database.
This query works fine if the values are hard-coded,
but the same query fails when i use String values (dynamically).
I use JDBC in the application to connect to sybase database.

I get the following error when i executed the code:
com.sybase.jdbc2.jdbc.SybSQLException:
ERROR=Parse failure on line 1 of statement 'update table1 set col1 = 0
where col2 = 'as-df-rt', at or near '''

I tried using PreparedStatement, it didn't work too!

Any help is appreciated
Following code snippet works, wherein col2 value is hard-coded:
updateQry = "update table1 set col1 =  0  where col2 = 'as-df-rt'";
stmt = con.createStatement();
int successQryResult = stmt.executeUpdate(updateQry );	
 
Following code snippet does not work, wherein col2 value is NOT hard-coded 
(col2 is a string i get from an ArrayList):
updateQry = "update table1 set col1 =  0  where col2 = " + colValue + "'";
stmt = con.createStatement();
int successQryResult = stmt.executeUpdate(updateQry );

Open in new window

0
Comment
Question by:chintan_sanghavi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Accepted Solution

by:
grant300 earned 250 total points
ID: 24067995
It looks as if you are taking an unmatched single quote on the end of your updateQry string and Sybase is whining about it.

Regards,
Bill
0
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 250 total points
ID: 24068292
If colValue is declared as a string or char variable, then this would ssuffice:

updateQry = "update table1 set col1 =  0  where col2 = " + colValue;

Hope this helps.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
We have put together a white paper that aims to explain how MSPs can both improve their offering and ease the pain of after-hours service by: -Suggesting changes to workflow -Indicating how to rework policy to suit your team -Providing ConnectW…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question