• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

SQLite and id parameter

 
Greenhorn
Posts: 9
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have created a database with SQlite - file created - table view works -

but when I try to add new data (row) a error appears ...



Insert statement





If I put (NULL, 'Paul', '10.10.2032', 'California', 'old') for id .. then  A NOT NULL constraint failed (NOT NULL constraint failed: PEOPLE.ID) appears

Any ideas?

Edit: If I use ID INT PRIMARY KEY   AUTOINCREMENT  NOT NULL - not null error appears also

In IntelliJ IDEA  id, Info and Autoincrement looks different




 
Saloon Keeper
Posts: 6392
60
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is that you are telling it that you're going to pass an ID yet you don't. So, don't tell it to expect an ID.
String sql = "INSERT INTO BEWOHNER (NAME,DATE,ACTION, INFO) VALUES ('Paul', '10.10.2032', 'California', 'supi')";

It's either that or tell it to expect an ID and give it null.
 
Rancher
Posts: 4301
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have set the field to AUTOINCREMENT then you don't need to provide it at all.
That includes in the list of fields in the INSERT statement.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!