i've got issue , nice receive feedback you. while updating data of table in mysql, following message appears:
column count doesn't match value count @ row 1
the table is:
idusuari
int not null auto_increment,nickname
varchar(50) not null,dataregistre
date not null,datadarreracces
date not null,numllistes
int not null default 0,password
varchar(10) not null,admin
int not null, primary key (idusuari
)
and code:
public static void registreusuari(int port, string ip, string nickname, string password) throws sqlexception{ /*creem un usuari*/ java.util.date dt = new java.util.date(); connection conn = getconnection(port,ip); statement st = null; st = conn.createstatement(); string query = new string(); /*data*/ java.text.simpledateformat sdf = new java.text.simpledateformat("yyyy-mm-dd hh:mm:ss"); string currenttime = sdf.format(dt); query = "insert usuari(nickname, password, dataregistre, datadarreracces, numllistes, admin) values('" + nickname +"','"+password+"','"+currenttime+"','"+currenttime+"',0)"; st.executeupdate(query); }
and
database.registreusuari(port, ip, "elder", "hola");
thank in advance!
you trying insert 5 values table 6 columns. don't specify value numllistes
.
if wish default value used, don't specify numllistes
column in insert statement :
query = "insert usuari(nickname, password, dataregistre, datadarreracces, admin) values('" + nickname +"','"+password+"','"+currenttime+"','"+currenttime+"',0)";
Comments
Post a Comment