JSP中如何取得MSSQL數據庫表中自動增長的ID主鍵值?
如:建一個表student有屬性列userid
先創建存儲過程:
CREATE PROCEDURE addrec
(
@OutID int output
@Name varchar(
)
AS
Declare @ID int
insert into nametable(Name)
values(@Name)
select @ID=@@IDENTITY
select @OutID=@ID
GO
然後這樣用:
CallableStatement stmt=con
stmt
stmt
stmt
int id=stmt
stmt
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20637.html