我想从类 DATAENTRY 的文本字段中获取值到我当前的类 SoilTable 中,以使表正常工作
private void btgetinvActionPerformed(java.awt.event.ActionEvent evt) {
try { //my class DATAENTRY from which i have to fetch the value of textfield tf_rm_id
DBUtil util = new DBUtil();
Connection con = util.getConnection();
PreparedStatement stmt = con.prepareStatement("select COUNT(box_no)as total from mut_det WHERE rm_id = ?");
ResultSet rs;
String rm = tf_rm_id.getText().trim();
stmt.setInt(1, Integer.parseInt(rm));
rs = stmt.executeQuery();
while (rs.next()) {
tf_boxno.setText(rs.getString("total"));
}
这是我的课程,我想用文本字段 tf_rm_id 的值替换 ? 范围
try { // My current class SoilTable
DBUtil util = new DBUtil();
Connection con = util.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from soil_det where rm_id=?");
String rmn = (tf_rm_id.getText() == null || tf_rm_id.getText().equals("")) ? "0" : tf_rm_id.getText();
stmt.setLong(1, Long.parseLong(rmn));