title: Java JDBC SQL Query Result Inconsistency
body: <p>Submitting a query from SQLiteStudio returns the expected result from a View.
  However, when the same query is sent from my program in java, the result is different for some queries.</p>
  <p>ie: SELECT Rev FROM PartRevs WHERE PartNumber = '800111'</p>
  <p>This returns the expected result of <strong>&quot;B&quot;</strong> when executed within SQLiteStudio. However, then the same query is executed from JAVA, it returns <strong>&quot;A&quot;</strong>. Only one result is returned with both queries.</p>
  <p>This does not happen consistently. Most queries work, but it occasionally does not work.</p>
  <p><img src="https://i.stack.imgur.com/AGY6x.png" alt="Picture of 'PartRevs' View within SQLiteStudio" /></p>
  <p><img src="https://i.stack.imgur.com/U6Xjd.png" alt="Picture of DDL for the 'PartRevs' View" /></p>
  <p>The 'Rev' or Revision of a given part is pulled from another table called 'ECO_TDA_Linewise'. Each time a new revision is released for a given part, a new line is added with increasing index numbers.</p>
  <p><img src="https://i.stack.imgur.com/NbqkF.png" alt="Picture of 'ECO_TDA_Linewise' Table" /></p>
  <p>I believe the problem comes from the way the 'PartRevs' view works. Of the many other tables and queries, this is the only one that has an issue.</p>
  <p>Here are the code blocks that interact with the database:</p>
  <pre><code>public String GetRevision(String PartNumber) {
          String sqlStatement = &quot;SELECT Rev FROM PartRevs WHERE PartNumber = '&quot; + PartNumber + &quot;'&quot;;
          return getDatabaseResult(sqlStatement, &quot;Rev&quot;);
      }
  </code></pre>
  <pre><code>public String getDatabaseResult(String sqlStatement, String Column) {
          String result = &quot;&quot;;
          try (Connection conn = FulfillmentWorkorders.connect();
                  Statement stmt = conn.createStatement();
                  ResultSet rs = stmt.executeQuery(sqlStatement)) {
  
              result = rs.getString(Column);
              conn.close();
  
          } catch (SQLException e) {
              System.out.println(&quot;\&quot;&quot; + sqlStatement + &quot;\&quot; throws exception: &quot; + e.getMessage());
          }
          return result;
      }
  </code></pre>