mysql - data not getting inserted into database -
hi guys have strange problem.. in local server data getting inserted database on remote server data not getting inserted in database , dont know do, plz me, using mysql database, not getting error, here code
enter code here int res=0; try { string q2="select count(*) studentscoredetails student_id='"+username+"' , lo_id='"+lo_id+"' , group_id='"+g_id+"'"; statement stmt=con.createstatement(); resultset rs=stmt.executequery(q2); while(rs.next()){ res=rs.getint(1); } }catch(sqlexception e1){ e1.printstacktrace(); } system.out.print(res+">>>>>>>>>>>>>>>>>>>>>>>>>>>>"); if(res>0){ string q="select percentage studentscoredetails student_id='"+username+"' , lo_id='"+lo_id+"' , group_id='"+g_id+"'"; statement checkrow=con.createstatement(); resultset r=checkrow.executequery(q); string finish="not finished"; int p=0; while(r.next()){ if(p < r.getint(1) ){ p=r.getint(1); } if(p > 40){ finish="finished"; } string q1="update studentscoredetails set percentage='"+p+"', quiz_status='"+finish+"',retest='n' student_id='"+username+"' , lo_id='"+lo_id+"' , group_id='"+g_id+"'"; statement update=con.createstatement(); int j=update.executeupdate(q1); system.out.print(j+"update success"); } }else{ system.out.print(list.size()+"inside"); if(list.size()>0){ system.out.print(list.size()+"inside"); try{ preparedstatement insertstdetails=con.preparestatement("insert studentscoredetails (student_id,quiz_id,subject,topic,lo_name,percentage,timetaken,lo_id,group_id,quiz_status,r etest) values (?,?,?,?,?,?,?,?,?,?,?)"); insertstdetails.setstring(1,username); insertstdetails.setint(2,qid); insertstdetails.setstring(3,subject); insertstdetails.setstring(4,topic); insertstdetails.setstring(5,lo); insertstdetails.setint(6, percentage); insertstdetails.setstring(7,timetakenstr); insertstdetails.setint(8,lo_id); insertstdetails.setint(9,g_id); insertstdetails.setstring(10,quiz_status); insertstdetails.setstring(11,"n"); int i=insertstdetails.executeupdate(); //system.out.print("execute"+i); }catch(sqlexception e2){ e2.printstacktrace(); } } }
Comments
Post a Comment