铭毅小子

调用存储过程,返回字段

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();
}

posted on 2018-03-29 10:49  铭毅小子  阅读(238)  评论(0编辑  收藏  举报

导航