title: Java Update JLabel With Database Output
body: <p>so what I am trying to do is update a JLabel that is going to represent the number of files that are stored in my database.</p>
  
  <p>I will use JDBC to communicate my Java application with my database (Oracle) and pass a SQL statement to my database to return output in this case it will be: <code>SELECT COUNT(File_ID) FROM Files;</code> which would give an output of say 50.</p>
  
  <p>So now I would like to update my Jlabel I have to display the output, in this case it would read 50.</p>
  
  <p>I know how to update a JTable with the results from a database like so: </p>
  
  <pre><code>try {
      String query = "SQL STATEMENT GOES HERE";
      pat = conn.prepareStatement(query);
      rs = pat.executeQuery();
      myTable.setModel(DbUtils.resultSetToTableModel(rs));
  }catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>However I have never used output to update a Jlabel, if you have any suggestions or advice on how to achieve this it would be greatly appreciated. Thanks!</p>