HashMap<Integer,Object> exec(String spname,HashMap<String,Object> params);
如:
Mysql存储过程:
DROP PROCEDURE `myadd` ;
CREATE DEFINER = `root`@`localhost` PROCEDURE `myadd` ( IN `a` INT, IN `b` INT, OUT `c` INT, INOUT `d` INT ) NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER BEGIN #Routine
body goes here...
SELECT a + b
INTO c;
SELECT b + d
INTO d;
SELECT *
FROM jkas_members;
SELECT *
FROM jkas_test;
SELECT *
FROM jkas_user;
END
Java调用:
HashMap<String,Object> params=new
HashMap<String,Object>();
params.put("1",79);
params.put("2",88);
params.put("3>","integer");//>代表为输出参数,值为输出参数类型,类型见下面说明。
params.put("4a","99ainteger");a代表为输入输出参数,a可以是除了数字和>的任意字符,但必须确保与值不重复;字符前表示输入值,字符后面表示输出类型,类型说明参见下面。
HashMap<Integer,Object> a=m.ex ec("myadd(?,?,?,?)",params);
返回值说明:
0:ArrayList<ArrayList>//结果集,如果存储过程有结果集产生,则返回,有多个则返回多个
1~n:则是对应输出参数的值,参字符串形式返回
输出类型说明:
bigint
binary
bit
blob
char
clob
date
decimal
double
float
integer
java_object
longvarbinary
longvarchar
numeric
other
real
smallint
time
timestamp
tinyint
varbinary
varchar