title: Assigning SELECT COUNT(*) Query Result to a Java Variable
body: <p>I have been having problems assigning the result of a <code>SELECT COUNT(*)</code> query to a Java variable. I am assigning the result of the query to a ResultSet.  Then, I am trying to retrieve the value of the count and assigning it to a variable.  I am getting an error when trying to do this.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ResultSet rc1 = null;
  int rowCount1;
  Statement stat = conn.createStatement();
  
  rc1 = stat.executeQuery("SELECT COUNT(*) AS rowcount1 
     FROM Signal WHERE SignalId = 1;");
  
  if (rc1.next())
          rowCount1 = rc1.getInt("rowcount1");
  </code></pre>
  
  <p>Then I get the following error:</p>
  
  <blockquote>
    <p>java.sql.SQLException: no such column: 'rowcount1'<br>
    at org.sqlite.RS.findColumn(RS.java:116)<br>
    at org.sqlite.RS.getInt(RS.java:219)</p>
  </blockquote>
  
  <p>Apparently, the problem is when trying to assign what goes after AS to a variable.  I can't find a lot of information on queries containing AS.  I get the same error with queries where I am not counting.  For example if I have the following code:</p>
  
  <pre><code>ResultSet rp1 = null;
  int rowCount1 = 0;
  Statement stat = conn.createStatement();
  
  rp1 = stat.executeQuery("SELECT Signal AS Sig1 
    FROM Observations WHERE SignalId = 1;");
  
  if (rp1.next())
         rowCount1 = rp1.getInt("rowcount1");
  </code></pre>
  
  <p>I get the same error with the previous code (no such column: rowCount1). What I am doing wrong?  I am making sure the table I am reading contains the correct values so the query has to be true.</p>