java - Insert multiple rows from Jtable to sql database table -


i'm trying insert rows data jtable table in sql database on runtime facing error

incorrect syntax near keyword 'transaction'.

here code

try {      int rows = table.getrowcount();      //  con.setautocommit(false);     string query = "insert transaction(transaction_code, transaction_date, item_code, item_name, quantity, item_price, total) values (?,?,?,?,?,?,?) ;";     preparedstatement pst = con.preparestatement(query);     (int row = 0; row < rows; row++) {         int t_code = (int) table.getvalueat(row, 0);         timestamp t_date = (timestamp) table.getvalueat(row, 1);         int i_code = (int) table.getvalueat(row, 2);         string i_name = (string) table.getvalueat(row, 3);         int quantity = (int) table.getvalueat(row, 4);         bigdecimal i_price = (bigdecimal) table.getvalueat(row, 5);         bigdecimal total = (bigdecimal) table.getvalueat(row, 6);         pst.setint(1, t_code);         pst.settimestamp(2, t_date);         pst.setint(3, i_code);         pst.setstring(4, i_name);         pst.setint(5, quantity);         pst.setbigdecimal(6, i_price);         pst.setbigdecimal(7, total);          pst.addbatch();     }     pst.executebatch();     pst.execute(query);     //con.commit(); } catch (exception e1) {     e1.printstacktrace();  } 

transaction keyword in mysql many other dbms. not use tablename or escape backticks


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -