title: Record cannot be inserted in table with Integer Primary Key field
body: <p>I have a table in SQLite database with its ID field as <code>integer primary key</code> (hence <code>autoincrement</code>ed ). I have following query to insert the record in the table.</p>
  <pre><code>INSERT INTO users(fname, lname, email, password) VALUES('Foo','Bar','foo@bar.com','12345');
  </code></pre>
  <p>While the first field <code>u_id</code> is omitted. This query runs fine from terminal and I'm able to insert record, but doing so from Java throws <code>SQLException</code> with message <code>users.u_id may not be NULL</code>. I'm using <code>PreparedStatement</code> with following query:</p>
  <pre><code>INSERT INTO users(fname, lname, email, password) VALUES(?,?,?,?)
  </code></pre>
  <p>What am I doing wrong here?</p>
  <p><strong>Note:</strong>
  I'm using SQLite 3, with JDBC driver <a href="http://webcache.googleusercontent.com/search?q=cache:sm3IEtsiaxsJ:www.zentus.com/sqlitejdbc/%20&amp;cd=4&amp;hl=en&amp;ct=clnk&amp;gl=in" rel="nofollow noreferrer">SQLiteJDBC</a> (the site is closed but I do have the <code>jar</code> file downloaded earlier). Is it something to do with drivers?</p>
  <h2>Update:</h2>
  <p>Here's stack trace of exception thrown:</p>
  <pre><code>java.sql.SQLException: users.u_id may not be NULL
  at org.sqlite.DB.execute(DB.java:275)
  at org.sqlite.DB.executeUpdate(DB.java:281)
  at org.sqlite.PrepStmt.executeUpdate(PrepStmt.java:77)
  at com.paperfood.DatabaseManager.insertUser(DatabaseManager.java:64)
  at com.paperfood.controller.RegisterUser.doPost(RegisterUser.java:62)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  <p>And following is my record insertion Java code:</p>
  <pre><code>PreparedStatement pst = con.prepareStatement(&quot;INSERT INTO users(fname, lname, email, password) VALUES(?,?,?,?)&quot;);
  pst.setString(1, user.getFirstName());
  pst.setString(2, user.getLastName());
  pst.setString(3, user.getEmail());
  pst.setString(4, user.getPassword());
  pst.executeUpdate();
  </code></pre>
  <p>Where, <code>user</code> is object of entity class with fields mapped to table fields. Also, note that my controller (<code>RegisterUser</code> servlet) is using <code>DatabaseManager</code> class to insert record and the <code>DatabaseManager</code> class has method <code>insertUser()</code> which accepts argument of entity class' object of class <code>User</code>.</p>
  <p>Following is SQL to create table <code>users</code>:</p>
  <pre><code>CREATE TABLE users(
      u_id integer PRIMARY KEY,
      fname varchar(30),
      lname varchar(30),
      email varchar(30),
      password varchar(32)
  );
  </code></pre>