 <p>Note the <a href="http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html" rel="nofollow"><code>Statement</code> documentation</a> says:</p> <blockquote> <p>By default, only one ResultSet object per Statement object can be open at the same time. </p> </blockquote> <p>Now, you have these statements in your program:</p> <pre><code>ResultSet resultset = statement.executeQuery("select * from customer where first_name = '" + first_name + "'") ; statement.executeQuery("select * from customer where last_name = '" + last_name + "'") ; statement.executeQuery("select * from customer_order where amount = '" + amount + "'") ; statement.executeQuery("select * from customer_order where date_created = '" + date_created + "'") ; statement.executeQuery("select * from customer_order where reference_number = '" + reference_number + "'") ; statement.executeQuery("select * from customer_order where invoice_number = '" + invoice_number + "'") ; statement.executeQuery("select * from customer_order where status = '" + status + "'") ; statement.executeQuery("select * from ordered_product where quantity = '" + quantity + "'") ; statement.executeQuery("select * from ordered_product where product_name = '" + product_name + "'") ; statement.executeQuery("select * from ordered_product where product_price = '" + product_price + "'") ; </code></pre> <p>This means you are calling the <code>executeQuery</code> several times with the same <code>Statement</code> object. But you are only saving the result of the first execution into <code>resultset</code>.</p> <p>That is, the <code>ResultSet</code> object that <code>resultset</code> refers to is the one from this statement:</p> <pre><code>statement.executeQuery("select * from customer where first_name = '" + first_name + "'") ; </code></pre> <p>All the others that follow it are separate queries and are not stored in the same variable if that's what you thought you were doing. They just create the <code>ResultSet</code> object, and then it gets thrown away because you don't assign the result to any variable.</p> <p>As soon as you call the second <code>executeQuery</code>, because only one <code>ResultSet</code> object is allowed, the <code>ResultSet</code> object stored in <code>resultset</code> is closed, and a new one is opened. Then another, and then another.</p> <p>Anyway, after you go through all these statements, you get to the part where you check <code>resultset.next()</code>. But at this point, that object, as I said, has already been closed.</p> <p>Basically, you should decide which of the queries you want to run, run only <em>that particular query</em>, and then you'll have a live, open <code>ResultSet</code> in <code>resultset</code>. And then you can fill it in.</p> <hr> <p>In addition, the part that prints the values from the result set should be inside the <code>else</code> block. You placed them after the curly brace of that <code>else</code>, which means you'll have trouble when no rows are returned from the query, because you'll be trying to print them anyway.</p>