Reason for "Invalid Jdbc Escape Syntax at Line Position 24 '=' Character Expected" Error When Executing Sql Server Call Through Jtds Driver?

I am trying to execute the following piece of SQL on SQL Server 2012, using a Java program, connecting to the database with the JTDS driver:

Declare @username varbinary(128); 
SET @username=convert(varbinary(128), ?); 
SET CONTEXT_INFO @username; 

I always get the following error:

Invalid JDBC escape syntax at line position 24 '=' character expected.

Any ideas?

2

1 Answer

I believe you are missing quotations marks around ?

SET @username=convert(varbinary(128), '?'); 
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest