sql - MySQL auto_increment not incrementing -


i'm using mysql 5.x , don't know why auto_increment isn't working. set addressid primary key in addressinformation , addressid in personalinformation foreign key addressinformation's addressid. cause? when update via workbench, it's working when update via jdbc, isn't working. throws , parameter index out of range error. here's code 2 tables

create table  personalinformation  (    username  varchar(50) not null,    lastname  varchar(50),    firstname  varchar(50),    middlename  varchar(50),    gender  char(1),    birthdate  varchar(50),    addressid  int not null,    email  varchar(50),    phonenumber  varchar(50),   primary key  ( username ) );  create table  addressinformation  (    addressid  int not null auto_increment,    country  varchar(50),    zipcode  varchar(50),    state  varchar(50),    city  varchar(50),    street  varchar(50),    housenumber  varchar(50),   primary key  ( addressid ) );  alter table  personalinformation  add constraint  personalinformation_fk1  foreign key ( addressid ) references addressinformation( addressid ); 

and code in servlet:

private void todatabase(personalbean p)     {         try         {             class.forname("com.mysql.jdbc.driver");             connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/foundationsystem","root","!qaz2wsx");             preparedstatement stmt1;             stmt1 = con.preparestatement("insert addressinformation (country, zipcode, state, city, street, homenumber) values (?,?,?,?,?,?)");             stmt1.setstring(2, "testcountry");             stmt1.setstring(3, p.getfirstname());             stmt1.setstring(4, "teststate");             stmt1.setstring(5, "testcity");             stmt1.setstring(6, "teststreet");             stmt1.setstring(7, "testhouse");             stmt1.executeupdate();         }         catch (exception e)         {              system.out.println(e);         }     } 

if opinion right. this

sql fiddle


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -