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
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 2896
    
    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://zeroturnaround.com/jrebel/download
 
subject: Query Works in SQL, but Not in Java? [SOLVED]
 
Similar Threads
JSP not getting results from Bean
Invalid MySQL syntax when using 'select new list()'
Are Column names case sensitive in SQL queries?
Best Way to Turn Query to String[][]
Best Way to Exclude Results Based on Unrelated Query