0
我想從類的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"));
}
這是我的課堂,我想要替換textfield 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));
是textfield聲明爲 私有? –
是什麼問題? – vels4j