private void bt_commit1ActionPerformed(java.awt.event.ActionEvent evt) {
DBUtil util = new DBUtil();
try {
Connection con = util.getConnection();
PreparedStatement stmt = con.prepareStatement("INSERT INTO dbo.bk_det(rm_id,bk_name,bk_branch) VALUES (?,?,?)");
String rm = (tf_rm_id.getText().trim() == null || tf_rm_id.getText().equals("")) ? "0" : tf_rm_id.getText();
String a = (txtbkname.getText().trim() == null || txtbkname.getText().equals("")) ? "UNKNOWN" : txtbkname.getText();
String b = (txtbkbranch.getText().trim() == null || txtbkbranch.getText().equals("")) ? "UNKNOWN" : txtbkbranch.getText();
stmt.setString(1, ""+(rm));
stmt.setString(2, ""+(a));
stmt.setString(3, ""+(b));
stmt.execute();
JOptionPane.showMessageDialog(null, "COMMITED SUCCESSFULLY!");
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
}
我实际上想在不使用 sql 数据库的情况下将值存储在表中。在这里,我正在使用 sql 语句连接到我的数据库,但我想在没有数据库的情况下将 netbeans 中的 java gui 中的值存储到 jtabel