title: JDBC ResultSet fails to store query results
body: <p>I am currently trying to run a query on an Oracle database through the JDBC. I have tested my queries in SQLDeveloper, but when I try to run the queries within my Java program, my ResultSet rs.next() result returns false (meaning there isn't anything stored in rs).</p>
  
  <p>My code is below:</p>
  
  <pre><code>public static void testFunction() {
      Properties properties = new Properties();
      properties.put("user", "USERNAMEHERE");
      properties.put("password", "PASSWORDHERE");
  
      String URL = "jdbc:oracle:thin:@abc:123:def456";
      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      String sqltxt = "SELECT a.MESSAGE, a.DATE, a.ID_NUM, b.MESSAGE, b.ANOTHER_ID FROM USER.SOME_TABLE_NAME a INNER JOIN USER.DIFFERENT_TABLE_NAME b on a.MESSAGE = b.MESSAGE where a.DATE= '1-December-2014' and b.ANOTHER_ID = 3 and a.ID_NUM IN(0, 100)";
  
  
      try {
          conn = DriverManager.getConnection(URL, properties);
          stmt = conn.prepareStatement(sqltxt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          rs = stmt.executeQuery();
          System.out.println("Records exist? " + rs.next());
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          try { if (rs != null) rs.close(); } catch (Exception e) {};
          try { if (stmt != null) stmt.close(); } catch (Exception e) {};
          try { if (conn != null) conn.close(); } catch (Exception e) {};
      }
  }
  </code></pre>
  
  <p>I have noticed that whenever I add a WHERE clause to sqltxt, that is when my rs.next() yields false.</p>
  
  <p>Any insight is appreciated, if I happen to find the solution myself, I will post it here.</p>
  
  <p>EDIT: Here is the same code from above BUT with a different query for sqltxt:</p>
  
  <pre><code>public static void testFunction() {
      Properties properties = new Properties();
      properties.put("user", "USERNAMEHERE");
      properties.put("password", "PASSWORDHERE");
  
      String URL = "jdbc:oracle:thin:@abc:123:def456";
      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      String sqltxt = "SELECT MESSAGE FROM USER.SOME_TABLE WHERE DATE = '01-December-2015'";
  
      try {
          conn = DriverManager.getConnection(URL, properties);
          stmt = conn.prepareStatement(sqltxt, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          rs = stmt.executeQuery();
          System.out.println("Records exist? " + rs.next());
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          try { if (rs != null) rs.close(); } catch (Exception e) {};
          try { if (stmt != null) stmt.close(); } catch (Exception e) {};
          try { if (conn != null) conn.close(); } catch (Exception e) {};
      }
  }
  </code></pre>