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
593 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The conference as a whole was very interesting, although if one has to make a choice between this one and some others, you may want to check out the others.  This conference is aimed mainly at government agencies.  So it addresses the various compli…
Let’s face it: one of the reasons your organization chose a SaaS solution (whether Microsoft Dynamics 365, Netsuite or SAP) is that it is subscription-based. The upkeep is done. Or so you think.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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