aspose file tools*
The moose likes JDBC and the fly likes Query Works in SQL, but Not in Java? [SOLVED] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Query Works in SQL, but Not in Java? [SOLVED]" Watch "Query Works in SQL, but Not in Java? [SOLVED]" New topic
Author

Query Works in SQL, but Not in Java? [SOLVED]

Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

Hi,

I'm not sure why I can't get this to work...

The code is:



If I copy and past this into SQL Query Manager, it works fine:



When I run this in Java, I get "java.sql.SQLException:... Incorrect syntax near "."... at OfferClicked.getTestLink(OfferClicked.java:203)"

Why does this work in SQL, but not Java? Your help is much appreciated.

Best,
Al
Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

Nevermind. I figured it out. Seems that there was not enough space between the values.

Changed it to:



Now it works.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

For such long quires, you can always use string object to hold the query string.
like:


and you can edit and make the subject line as [SOLVED]... to let other know & save their time.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Al Johnston
Ranch Hand

Joined: May 02, 2009
Posts: 99

Thanks Sagar.

I will edit the forum topic.

Best,
Al
 
Consider Paul's rocket mass heater.
 
subject: Query Works in SQL, but Not in Java? [SOLVED]