Mysql存储过程(转)
时间:2021-07-01 10:21:17
帮助过:14人阅读
com.test;
import java.sql.*
;
public class Test {
public static void main(String[] args)
throws Exception {
String div="com.mysql.jdbc.Driver"
;
String url="jdbc:mysql://127.0.0.1:3306/mydb?characterEncoding=GBK"
;
String uid="root"
;
String pwd=""
;
Class.forName(div);
Connection conn =
DriverManager.getConnection(url,uid,pwd);
CallableStatement stat = conn.prepareCall("call BBB(?,?)"
);
stat.setString(1, "k001"
);
stat.registerOutParameter(2
, java.sql.Types.INTEGER);
ResultSet rs =
stat.executeQuery();
int i =stat.getInt(2
);
System.out.println(i);
while(rs.next()){
System.out.println(rs.getString(2
));
}
conn.close();
}
}
结果为:
Mysql存储过程(转)
标签:register targe rar 技术 bsp turn 行记录 type 数据库表