为什么所选行的值在文本字段中保持不变?

时间:2014-05-18 08:27:30

标签: java

我创建了一个jFrame,我在其中放了一个按钮,从数据库中获取信息以填充JTalble。 我添加了一个鼠标单击事件来设置jTextField中所选行的值。 问题是价值保持不变。

这是我的代码:

try {

    int row = jTable4.getSelectedRow();
    String str = (jTable4.getModel().getValueAt(row, 0).toString());
    String query = "select idclient from client where idclient = '"+str+"' "; 
    rs =(ResultSet) pst.executeQuery();

    if(rs.next()){

        String str4 = rs.getString("idclient");
        jTextField1.setText(str4);
    }
} catch (SQLException e) {

    Logger.getLogger(Display.class.getName()).log(Level.SEVERE, null, e);
}

0 个答案:

没有答案