aspose file tools*
The moose likes JDBC and the fly likes SQL Query returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Query returning null" Watch "SQL Query returning null" New topic
Author

SQL Query returning null

Anshal Patel
Ranch Hand

Joined: Feb 07, 2010
Posts: 32


The above query returns a null,here disquery is type of string where as this thing returns proper answer


Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
Make sure disquery String has value before the query execution.

Just printout the query before the execution and see how the query is constructed.


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Nothing to do with Servlets so moved to JDBC. Please choose forums carefully so you get the best possible answers.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

When not using PreparedStatements you have to make sure things are quoted, so first make sure your variable is not null. Then you'll need code that looks like:



Anshal Patel
Ranch Hand

Joined: Feb 07, 2010
Posts: 32
i have printed the variable and it works fine

I just need to know how to bind the parameter and my project is all done.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Anshal Patel wrote:i have printed the variable and it works fine

I just need to know how to bind the parameter and my project is all done.


Have a look at java.sql.PreparedStatement


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Anshal Patel wrote:i have printed the variable and it works fine

I just need to know how to bind the parameter and my project is all done.


This will help you.


Never try to be a hard-worker. Be a smart-worker.
My Blog
Anshal Patel
Ranch Hand

Joined: Feb 07, 2010
Posts: 32
issue resolved thanks to all
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SQL Query returning null