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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to reset your Windows 10 password when you've forgotten it.
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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