title: I have this error: java.sql.SQLException: Invalid column name in Java application
body: <p>I built an app that counts some tax forms in a table and has to insert the number in another table.
  When I count the tax forms in the first table I do it with this sql query :</p>
  
  <pre><code>select count(distinct cui) from dec_declaratii where id &gt; 142321849 and 
  tip_declaratie='D212' and anul_duk&gt;=2019 and cod_stare_prelucrare_intern 
  in ('DUK_VLD', 'GEN_MSJ')";
  </code></pre>
  
  <p>When I run it from Oracle Toad it works but when i put it in java and I try to get the result with rs.getString("count(distinct cui)") it gives me this error : 
  java.sql.SQLException: Invalid column name</p>
  
  <p>Why is this happening ? </p>
  
  <p>What can I do to make it work ? </p>
  
  <p>I tried writing count(distinct cui) with capital letters and if I write count(*) it works but I need the distinct number of tax forms.</p>
  
  <pre><code>public class Baza {
  
  int idmin = 142321849;
  int rezultat = 391320;
  
      String host = "xxx";
      String user = "xxx";
      String pass = "xxx";
      String user2 = "xxx";
      String pass2 = "xxx";
  
      String host2 = "xxx";
      String nr = "0";
  public void conectare() {
  
      try {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      Connection con = DriverManager.getConnection(host, user, pass);
      Statement st = con.createStatement();
      String sql = "select count(distinct cui) from dec_declaratii where id 
  &gt; 142321849 and tip_declaratie='D212' and anul_duk&gt;=2019 and 
  cod_stare_prelucrare_intern in ('DUK_VLD', 'GEN_MSJ')";
      ResultSet rs = st.executeQuery(sql);
      while(rs.next()) {
         nr = rs.getString("count(DISTINCT CUI)");
         System.out.println(nr);
      }
      }catch(Exception e) {System.out.println(e);}
      int nr2 = Integer.parseInt(nr);
  
      try {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      Connection con = DriverManager.getConnection(host2, user2, pass2);
       Statement st = con.createStatement();
       String sql = "update nr_tot_dec_212 set nr_dec='"+nr+"', data=sysdate 
  where id=1";
       st.executeUpdate(sql);
  
  
      }catch(Exception e) {System.out.println(e);}
   }
  
  }
  </code></pre>
  
  <p>I would like to get the result of the query : select count(distinct cui) from dec_declaratii where id > 142321849 and tip_declaratie='D212' and anul_duk>=2019 and cod_stare_prelucrare_intern in ('DUK_VLD', 'GEN_MSJ')"; in a Java variable. It gives me this error:java.sql.SQLException: Invalid column name</p>