 <p>You can do it like : </p> <pre><code>ResultSet rs = stmt.executeQuery(sql); String result = null; if (rs.next()) { // replace 'if' with 'while' to iterate if multiple records result = rs.getString("result"); } </code></pre> <p>if you have more records, you can replace <code>if</code> with <code>while</code> and can iterate over <code>ResultSet</code>.</p> <p>For the complete working example you can go through the <a href="http://www.mkyong.com/jdbc/jdbc-preparestatement-example-select-list-of-the-records/" rel="nofollow noreferrer">example here.</a></p>