 <p>I see a few pitfalls in your code, there are a few places where things can go wrong:</p> <p>First, use of regular statements. Use <a href="http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html">prepared statements</a> so you won't have problems with <a href="http://en.wikipedia.org/wiki/Sql_injection">SQL injection</a>.</p> <p>Instead of</p> <pre><code>statement = connection.createStatement(); </code></pre> <p>use</p> <pre><code>statement = connection.prepareStatement(String sql); </code></pre> <p>With this, your query becomes</p> <pre><code>"select distinct group_name From group_members where username= ?" </code></pre> <p>and you set username with</p> <pre><code> statement.setString(1, username); </code></pre> <p>Next, I don't like use of your <code>myDB</code> class. What if results is <code>null</code>? You're not doing any error checking for that in your <code>public List&lt;InterestGroup&gt; getGroups()</code> method. </p> <p><code>public void sendQuery(String query)</code> seems to me like it shouldn't be <code>void</code>, but it should return a <code>ResultSet</code>. Also, search on the net for proper ways to do JDBC exception handling.</p> <p>Also, this line:</p> <pre><code>new InterestGroup(results.getString("group_name"), myDB) </code></pre> <p>Why do you have <code>myDB</code> as a parameter?</p> <p>I'd suggest adding more <code>System.out.println</code> statements in your code so you can see where things can go wrong.</p>