title: SQLException java.sql.SQLException: Field 'userid' doesn't have a default value
body: <p>My <code>user</code> table has previously string primary key now i added a new field <code>userid bigint(20)</code> and made this primary key.
  then added</p>
  
  <pre><code>ALTER TABLE smsusers AUTO_INCREMENT = 2335;
  </code></pre>
  
  <p>Total records in user table are  2334 next record should take value 2335
  and should be auto incremented as records are added.</p>
  
  <p>Problem is while inserting data from my application it is showing
  following error</p>
  
  <pre><code>SQLException  java.sql.SQLException: Field 'userid' doesn't have a default value
  </code></pre>
  
  <p>How to resolve this problem</p>
  
  <p><strong>EDIT:</strong> while trying to insert new data</p>
  
  <pre><code>    INSERT INTO `dbname`.`smsusers` ( `password`, `fname`, `lname`,
   `mailid`, `dob`, `gender`) VALUES ('asdf', 'asdf', 'asdf',
   'asdf@asdf.com', '2013-10-10', 'm');
  </code></pre>
  
  <p>It is showing following error</p>
  
  <pre><code>#1062 - Duplicate entry '0' for key 1
  </code></pre>
  
  <p>EDIT: 
  Initially my primary key was id than i added userid and made this primary key </p>
  
  <p>MY table structure is</p>
  
  <pre><code>CREATE TABLE `smsusers` (
   `id` varchar(60) NOT NULL DEFAULT '',
   `password` varchar(50) NOT NULL,
   `fname` varchar(30) NOT NULL,
   `lname` varchar(30) DEFAULT NULL,
   `mailid` varchar(50) NOT NULL,
   `dob` date NOT NULL,
   `gender` varchar(10) NOT NULL,
   `city` varchar(70) DEFAULT NULL,
   `userid` int(20) NOT NULL DEFAULT '0',
   PRIMARY KEY (`userid`),
   KEY `id_pk_unique` (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
  </code></pre>
  
  <p>While inserting data in smsusers it it only taking default value at 0 not the incremented value.</p>