如何在jsp中调用sql server的存储过程
1个回答
展开全部
虽然在JSP中写JAVA代码很不好,但是你这个问题应该直接问 java中如何调用 sql server存储过程,因为 JSP中 无法写的也是 JAVA connection 连接,做持久化操作;
public static void executeSprocInParams(Connection con) {
try {
PreparedStatement pstmt = con.prepareStatement("{call dbo.uspGetEmployeeManagers(?)}");
pstmt.setInt(1, 50);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
System.out.println("EMPLOYEE:");
System.out.println(rs.getString("LastName") + ", " + rs.getString("FirstName"));
System.out.println("MANAGER:");
System.out.println(rs.getString("ManagerLastName") + ", " + rs.getString("ManagerFirstName"));
System.out.println();
}
rs.close();
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
原文地址:http://blog.csdn.net/java2000_net/article/details/2311956
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询