存储过程调用
Connectin conn = DBUtil.getConnection();DatabaseMetaData dbmd = conn.getMetaData(); //获取数据库数据元//获取存储过程的参数列表ResultSet rs = dbmd.getProcedureColumns(packageName, "", procedure, null);while(rs.next()){String columnName=rs.getString(" COLUMN_NAME");//获取参数名称int columnType = rs.getInt(" COLUMN_TYPE");//获取参数类型in dateType = rs.getInt(" DATA_TYPE");//获取参数数据类型}String sql = "{call procedureName(p1=>?,p2=>?,p3=>?,p4=>?)}";CallableStatement call=conn. prepareCall(sql);//获取存储过程对象call.setObject(1,obj1);//传入参数call.setObject(2,obj1);call.registerOutParameter(2,obj2_sql_type);//声明返回数据类型call.registerOutParameter(3,obj3_sql_type);call.registerOutParameter(4,obj4_sql_type);call.execute();//调用存储过程Object val2= call.getObject(2);//获取返回参数值Object val3=call.getObject(3);Object val4=call.getObject(4);call.commit();//提交call.close();//关闭rs.close();conn.close();