Connection conn = null;
CallableStatement proc = null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost; DatabaseName=数据库";
String username = "sa";
String password = "密码";
// String password = "111111";
conn = DriverManager.getConnection(url, username, password);
proc = conn.prepareCall("{call zz_GetICMaxNumOld(?,?)}");
//给存储过程的参数设置值
proc.setString(1,"cdgl_clyupai");
proc.registerOutParameter(2, Types.VARCHAR);
proc.execute();
fid_z = Integer.parseInt(proc.getString(2));
System.out.println("存储过程返回的值是:"+fid_z);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
来源:https://www.cnblogs.com/myxz/p/8668495.html