wood burning stoves 2.0*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query Works in SQL, but Not in Java? [SOLVED]
 
Similar Threads
Invalid MySQL syntax when using 'select new list()'
Best Way to Exclude Results Based on Unrelated Query
JSP not getting results from Bean
Best Way to Turn Query to String[][]
Are Column names case sensitive in SQL queries?