• Post Reply Bookmark Topic Watch Topic
  • New Topic

Insert ArrayList into MySQL  RSS feed

 
John Joe
Ranch Hand
Posts: 437
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I trying to insert ArrayList into MySQL, but I only gets the last values in column selected_seats. The variable list holds value 2 and 3. When I check MySQL, only value 3 get inserted, 2 is not inserted.




What's wrong here ?
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you supposed to insert Lists into databases at all? I can't remember. What sort of datatype is selected_seats declared as in the database?
 
John Joe
Ranch Hand
Posts: 437
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Are you supposed to insert Lists into databases at all? I can't remember. What sort of datatype is selected_seats declared as in the database?


I want it insert into column selected_seats and the column will have value 2,3. Is it possible ? Between, the datatype is int.
 
John Joe
Ranch Hand
Posts: 437
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the answer from http://stackoverflow.com/a/37365822/5156075
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What using a String? Ouch! And read this too. It applies to the people on SO, too.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The proper solution would probably be to create an extra table with a many-to-one relation to this table.
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Rob sys.
This is a relationship, so should be modelled as one.
Especially when your seat map for the particular cinema screen will need to know what seats are taken...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!