我有一个程序,它接受用户名并输出一个自动身份ID,如下所示。我的目标是在按下按钮时在文本字段中显示过程的输出,如下面的java代码中所示。到目前为止,该过程运行良好,但不显示输出。请求我帮忙。
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt)
{
try {
conn = inventconnect.ConnecrDb();
stored_pro = conn.prepareCall("{call getentry(?)}");
stored_pro.setString(1, this.txt_userrinfo.getText());
stored_pro.execute();
if (rs.next()) {
String add1 = rs.getString("entry_id");
jTextField1.setText(add1);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
}
-
create procedure getentry
(
@user_name nvarchar(50)
)
as
begin
INSERT INTO entry_no(user_name,entry_type)
VALUES(@user_name,'PO')
SELECT SCOPE_IDENTITY() as entry_id
end