Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes Problem while using prepared statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem while using prepared statement" Watch "Problem while using prepared statement" New topic

Problem while using prepared statement

Aashima Upadhyaya

Joined: Apr 23, 2011
Posts: 3
I have created the following program using prepared statement, but I am not able to go through and fetch its output accordingly.Please help.This is the program

Thanks in advance.

Aashima Upadhyay
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32628

Welcome to CodeRanch!

Just to make sure I'm understanding the problem correctly:

Works as expected:

Doesn't work as expected:

Can you try it with the values hardcoded in both as I have it (with the correct values of course.) I'm wondering if the variable somehow doesn't have what you expect. The JDBC looks fine.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Aashima Upadhyaya

Joined: Apr 23, 2011
Posts: 3
Thanks a lot but it still doesn't works. The code doesnt gives any error at any step but the value of s1 and s2 doesnt reaches to the query

I tried inserting the value manually in place of s1 and s2 it works perfectly well. Please help me out...


Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 802


Instead of constructor use following assignment operations in action performed method at line number 45 & 46

Let us know whether values are comming or not after above change

SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Aashima Upadhyaya

Joined: Apr 23, 2011
Posts: 3
Thanks a lot Ninad Sir,it worked perfectly well for timely reply... you are a savior.
I agree. Here's the link:
subject: Problem while using prepared statement
It's not a secret anymore!