Java代码:
public class invokeSP {
public static void main(String[] args) {
String driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url="jdbc:sqlserver://192.168.0.3:1433;DatabaseName=CTU_WMS";
String username="CTU_WMS_user";
String password="ctuwms";
Connection cn = null;
try {
Class.forName(driverClassName);
cn = DriverManager.getConnection(url,username,password);
// 返回單個結果的存儲過程
// outputProcedure(cn);
// 返回结果集的存储过程
resultProcedure(cn);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
cn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* 调用返回单个结果集的存储过程
*/
public static void resultProcedure(Connection conn){
String sql = "{call my_sp_test(?,?,?)}";
CallableStatement cstmt = null;
ResultSet rs = null;
try {
cstmt