Sql 在jsp页面中使用事务查询

Sql 在jsp页面中使用事务查询,sql,jsp,Sql,Jsp,我在jsp页面中使用下面的查询。但我不确定在jsp页面中使用此查询是否正确 int i = st.executeUpdate("'BEGIN TRANSACTION DECLARE @id [int] SELECT @id = SCOPE_IDENTITY() INSERT INTO Viewer(Reserve_ID, F_Name, L_Name, Competition_ID, City, Phone, [E-mail]) VALUES (@id, '" + fname + "','"

我在jsp页面中使用下面的查询。但我不确定在jsp页面中使用此查询是否正确

int i = st.executeUpdate("'BEGIN TRANSACTION DECLARE @id [int] SELECT @id = SCOPE_IDENTITY() INSERT INTO  Viewer(Reserve_ID, F_Name, L_Name, Competition_ID, City, Phone, [E-mail]) VALUES (@id, '" + fname + "','" + lname + "','" + 30 + "','" + city + "','" + phone + "','" + email + "' ) INSERT INTO  Reservation_Inf(Reservation_Date, Competition_ID, NumberOfTicket, Position_ID) VALUES ('" + dNow + "','" + 30 + "','" + 1 + "','" + 8 + "' ) COMMIT TRANSACTION '" );

if (i > 0) {
   response.sendRedirect("Success.jsp");
} else {
   response.sendRedirect("Fail.jsp");
}
它给出了以下错误:

 Incorrect syntax near 'BEGIN TRANSACTION DECLARE @id [int] SELECT @id = SCOPE_IDENTITY() INSERT INTO  Viewer(Reserve_ID, F_Name, L_Name, Competition_ID,'.