/*加载驱动*/
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connStr="jdbc:sqlserver://localhost:1433;DatabaseName=testDatabase";
/*建立连接*/
Connection conn=DriverManager.getConnection(connStr,"sa","******");
String callExchangeMoneyStr="{call exchangeMoney1(1,2,100)}";
/*调用存储过程*/
CallableStatement procedure=conn.prepareCall(callExchangeMoneyStr);
/*得到执行结果*/
ResultSet rs = procedure.executeQuery(); |