title: auto increment primary key value gives null values error
body: <p>I am trying to insert data into Microsoft server management studio table using "Spring MVC" project. </p>
  
  <p>Contact id has been set as <code>NOT NULL</code> and <code>AUTO INCREMENT by 1</code>. Even it is trying to insert null.</p>
  
  <p>I have define <code>user id</code> primary key not null and identity 1. Here is the query to create table : </p>
  
  <pre><code>CREATE TABLE contact (
    contact_id[int] IDENTITY(1,1) NOT NULL,
    name varchar(45) NOT NULL,
    email varchar(45) NOT NULL,
    address varchar(45) NOT NULL,
    telephone varchar(45) NOT NULL,
    PRIMARY KEY (contact_id)
  ) 
  </code></pre>
  
  <p>Table design:</p>
  
  <p><img src="https://i.stack.imgur.com/NjO9i.png" alt="table"></p>
  
  <p>Error:</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [SpringDispatcher] in context with path [/SpringMvcJdbcTemplate] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [INSERT INTO contact (name, email, address, telephone) VALUES (?, ?, ?, ?)]; Cannot insert the value NULL into column 'contact_id', table 'contactdb.dbo.contact'; column does not allow nulls. INSERT fails.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'contact_id', table 'contactdb.dbo.contact'; column does not allow nulls. INSERT fails.] with root cause
  com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'contact_id', table 'contactdb.dbo.contact'; column does not allow nulls. INSERT fails.
  </code></pre>
  
  <p>code lines: </p>
  
  <p>// insert</p>
  
  <pre><code>    String sql = "INSERT INTO contact (name, email, address, telephone)"
                  + " VALUES ('" + contact.getName() + "', '" + contact.getEmail() + "', '" + contact.getAddress() + "', '" + contact.getTelephone() + "')";
      jdbcTemplate.update(sql);
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>CREATE TABLE contact (
    contact_id int IDENTITY NOT NULL PRIMARY KEY,
    name varchar(45) ,
    email varchar(45) NOT NULL,
    address varchar(45) NOT NULL,
    telephone varchar(45) NOT NULL
  ) 
  </code></pre>