title: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'hourId' cannot be null
body: <p>My project is faculty allocation. when i try to insert data, it shows the following exception.</p>
  
  <pre><code>"com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: 
  Column 'hourId' cannot be null"
  </code></pre>
  
  <p>Can anyone help me how to overcome this problem?
  Please provide sample code to avoid this exception.</p>
  
  <p>My coding is </p>
  
  <pre><code>&lt;%
      Connection con = null;
      String StaffName = request.getParameter("StaffName");
     // String subcode = request.getParameter("subcode");
      String hourId = request.getParameter("hourId");
      String daysId = request.getParameter("daysId");
      String date = request.getParameter("date");
  
  
    //String queryText = "insert into tblstaffallocation (StaffName, subcode,hourId, daysId, date) values('"+StaffName+"','"+subcode+"','+hourId+','+daysId+','+date+')";
  
      try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/StaffAllocation","root","success");
  
         // PreparedStatement stat = con.PrepareStatement();
          String updateString ="INSERT INTO tblstaffallocation (StaffName,hourId,daysId,date) VALUES (?,?,?,?)";
  
          PreparedStatement preparedStatement = con.prepareStatement(updateString);
  
  
          preparedStatement.setString(1, StaffName);
          preparedStatement.setString(2, hourId);
          preparedStatement.setString(3, daysId);
          preparedStatement.setString(4, date);
          preparedStatement.executeUpdate();
          //int rst = stat.executeUpdate("insert into tblstaffallocation ('StaffName','hourId', 'daysId', 'date') values('"+StaffName+"','"+hourId+"','"+daysId+"','"+date+"')");
  
          %&gt;
          &lt;table cellpadding="4" border="1" cellspacing="4" align="center"&gt;
          &lt;th&gt;StaffName&lt;/th&gt;&lt;th&gt;hourId&lt;/th&gt;&lt;th&gt;daysId&lt;/th&gt;&lt;th&gt;date&lt;/th&gt;
          &lt;%
          Statement st=con.createStatement();
          ResultSet rs=st.executeQuery("select * from tblstaffallocation");
          while(rs.next()){
              rs.getString(1);
              rs.getString(2);
              rs.getString(3);
              rs.getString(4);
  
          }
          } catch (Exception e) { 
          out.print(e);
  
      }
  </code></pre>