?
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
Medium Priority
?
603 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 1000 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 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
The well known Cerber ransomware continues to spread this summer through spear phishing email campaigns targeting enterprises. Learn how it easily bypasses traditional defenses - and what you can do to protect your data.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 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