title: How to insert "count" and get "count" to JDBC DB Column?
body: <p>I want to make a small &quot;event apply page&quot; for training.</p>
  <p><em>(the event is First-come, first-served basis.)</em></p>
  <p>I'm using JSP, JAVA(DAO(Data Access Object)) and oracle JDBC.</p>
  <p>When a customer clicks &quot;apply&quot; button,</p>
  <p>[1. id], [2. apply date], [3. apply count (+1)] will be saved in db table that I made.</p>
  <p>I don't know how to make login session yet.
  So I made input field that can input id directly when applying.</p>
  <p>I can insert and get from db table about id and apply date.</p>
  <p>But I'm trouble because <em>&quot;apply&quot; counting.</em></p>
  <p>I will put limit that no more apply when &quot;apply count&quot; is 100. (First-come, first-served basis)</p>
  <p>How to insert apply count to DB and how to get count number from DB?</p>
  <p>here is my code and situation.</p>
  <p><strong>1. DB TABLE</strong></p>
  <p>Column that I made are 3
  [1. id] / [2. aug_cnt] / [3. applydate]
  <a href="https://i.stack.imgur.com/VyuEX.png" rel="nofollow noreferrer">enter image description here</a></p>
  <h2><strong>2. Applybean.java</strong></h2>
  <pre><code>package model;
  
  import java.sql.Timestamp;
  
  public class ApplyBean {
      
      private String id ;
      private int aug_cnt;
      private Timestamp applydate;
      
      public String getId() {
          return id;
      }
      public void setId(String id) {
          this.id = id;
      }
      public int getAug_cnt() {
          return aug_cnt;
      }
      public void setAug_cnt(int aug_cnt) {
          this.aug_cnt = aug_cnt;
      }
      public Timestamp getApplydate() {
          return applydate;
      }
      public void setApplydate(Timestamp applydate) {
          this.applydate = applydate;
      }
  
  }
  </code></pre>
  <p><strong>3. ApplyDAO.java</strong></p>
  <pre><code>public class ApplyDAO {     
  
      Connection con; 
      PreparedStatement pstmt; 
      ResultSet rs;   
      
      public void getCon() {          
          
          try {               
              Context initctx = new InitialContext();             
              Context envctx = (Context)initctx.lookup(&quot;java:comp/env&quot;);
              DataSource ds = (DataSource)envctx.lookup(&quot;jdbc/pool&quot;);
              con = ds.getConnection();
          }catch(Exception e) {
              e.printStackTrace();
          }    
      }
      
      public void insertApply(ApplyBean abean) {
  
          try{    
              getCon();                       
  
              String sql = &quot;insert into eventcount_aug values(?,sysdate)&quot;;
              PreparedStatement pstmt = con.prepareStatement(sql);
  
              pstmt.setString(1, abean.getId());
              pstmt.setTimestamp(2, abean.getApplydate()); 
              pstmt.executeUpdate();    
  
              con.close();
          }catch(Exception e){
              e.printStackTrace();
          }  
      }
  }
  </code></pre>
  <p>I think I need to edit only &quot;Applybean.java&quot; file...</p>
  <p>If I realize how to insert and get &quot;apply count&quot;,</p>
  <p>I can find how to make my event page perfectly.</p>
  <p>I would be really grateful for your help.</p>
  <p>Thank you.</p>