java - Update Jtable values to MySql table -
i want update mysql using jtable data. have 6 columns(periods,mon,tue,wed,thu,fri) in mysql. in jtable have same table in mysql. in mysql have given periods values(1,2,3,4).
connection con = driver.connect(); (int = 0; < 4; i++) { for(int j=1;j<=4;j++){ handler.setdata(con, "update sem1 set mon='"+jtable1.getvalueat(i, 1)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set tue='"+jtable1.getvalueat(i, 2)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set wed='"+jtable1.getvalueat(i, 3)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set thu='"+jtable1.getvalueat(i, 4)+"' periods='"+j+"'" ); handler.setdata(con, "update sem1 set fri='"+jtable1.getvalueat(i, 5)+"' periods='"+j+"'" ); } }
please read oracle tutorial jtable,
table in databases has similair structure jtable in swing,
(no idea code before) each of loops inside resultset returns 1 row, same order defined in sql query,
create array fills data database row , add arraya new row xxxtablemodel
search
resultsettablemodel
ortablefromdatabase
Comments
Post a Comment