好的,我知道Batch Processing允许将相关的SQL语句分组到一个批处理中,并通过一次调用数据库来提交它们.当您一次向数据库发送多个SQL语句时,可以减少通信开销,从而提高性能.在这种特殊情况下(见下面的代码)我认为批处理不是唯一的目的.stmt.executeBatch()添加批次后立即调用原因(?)不会stmt.executeUpdate()做同样的事情?
public void tableChanged(TableModelEvent e) {
int row = e.getFirstRow();
int col = e.getColumn();
model = (MyTableModel) e.getSource();
String stulpPav = model.getColumnName(col);
Object data = model.getValueAt(row, col);
Object studId = model.getValueAt(row, 0);
System.out.println("tableChanded works");
try {
new ImportData(stulpPav, data, studId);
bottomLabel.setText(textForLabel());
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
public class ImportData {
public ImportData(String a, Object b, Object c)
throws ClassNotFoundException, SQLException {
Statement stmt = …Run Code Online (Sandbox Code Playgroud)