• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.execu  RSS feed

 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to get the id of the inserted record with the use of getGeneratedKeys. but I am getting this error



How can I specify the Statement.RETURN_GENERATED_KEYS in the case of prepRoutesInsert.executeUpdate(); to get the id of the inserted raw?

I appreciate any help.

 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have change this line to



but I am getting " Column 'route_id' not found"? I have this coulmn in the routes table!
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us the details of that table.
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does INT(11) mean? Look here.
Why are you using an INT rather than a BIGINT for your primary key?

Still don't know why you aren't getting the route_id column back. Try select * from route at the command line.
 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am used to use it like this INT(11). It means Integer number with the long of 11 bit.

Like this I am geting the route_id back but I want to get the one of the inserted raw and not all the route_id in the routes table.


 
Alex Ardoin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed this line



to



and I am getting it back now.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
alex friday wrote: . . . It means Integer number with the long of 11 bit. . . .
If it is really 11 bits, that is far too few for your bus numbers. You will run out after 1023 and get an overflow error.

I thought it meant 11 decimal digits, but you can't fill 11 decimal digits with an INT.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!