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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now