jtable to database
Hi
i would like to ask on how to save all data on jtable to my database.
cause the data on jtable is imported only from excel files.
can anyone know the solution for that?
Hi
i would like to ask on how to save all data on jtable to my database.
cause the data on jtable is imported only from excel files.
can anyone know the solution for that?
i know there is a better solution to this problem.
save the data by row like this:
String sqlString = "update table set firstname = ?, lastname = ? where id = ?";
PreparedStatement pstmt = con.prepareStatement(sqlString);
for(int i = 0; i < table.getRowCount; i++){
con.setAutoCommit(false);
pstmt.setString(1,table.getValueAt(i, column1).toString());
pstmt.setString(2,table.getValueAt(i, column2).toString());
pstmt.setInt(3,4);
pstmt.executeUpdate();
con.commit();
}