title: java.sql.SQLException: Column 'Max(category_id' not found
body: <p>Here is my code. It gives me an exception error says "java.sql.SQLException: Column 'Max(category_id' not found.". Please help. Thanks in advance.</p>
  
  <p>enter code here</p>
  
  <p>public class Category extends javax.swing.JFrame {</p>
  
  <pre><code>/**
   * Creates new form Category
   */
  public Category() {
      initComponents();
      DisplayTable();
      autoID();
  }
  
  
  //Display Table
  private void DisplayTable() {
      try {
          Class.forName("com.mysql.jdbc.Driver");
          Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/inventory?useTimezone=true&amp;serverTimezone=UTC", "root", "ichigo197328");
          String sql = "SELECT * FROM category";
          PreparedStatement pstmt = conn.prepareStatement(sql);
          ResultSet rs = pstmt.executeQuery();
          jTable1.setModel(DbUtils.resultSetToTableModel(rs));
      }
      catch(Exception e) {
          JOptionPane.showMessageDialog(null, e);
      }
  }
  
  public void autoID() {
      try {
          Class.forName("com.mysql.jdbc.Driver");
          Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/inventory?useTimezone=true&amp;serverTimezone=UTC", "root", "ichigo197328");
          Statement s = conn.createStatement();
  
          ResultSet rs = s.executeQuery("SELECT Max(category_id) from category");
          rs.next();
  
          rs.getString("Max(category_id)");
  
          if(rs.getString("Max(category_id") == null) {
              CategoryIDField.setText("C0001");
          }
          else {
              Long id = Long.parseLong(rs.getString("Max(category_id").substring(2, rs.getString("Max(category_id").length()));
              id++;
              CategoryIDField.setText("C0" + String.format("%03d", id ));
          }
      }
      catch(ClassNotFoundException e) {
          Logger.getLogger(Category.class.getName()).log(Level.SEVERE, null, e);
      }
      catch(SQLException e) {
          Logger.getLogger(Category.class.getName()).log(Level.SEVERE, null, e);
      }
  }
  </code></pre>