当我从命令行调用存储过程时,会得到以下结果。
当我执行这个语句时,只有event_table的结果被返回。我使用以下方式来阅读查询:
CALL `events`.`get_event_by_id`(10)
+---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+
| evet_id | name | description | starttime | endtime | last_modified | active | addre_id |
+---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+
| 10 | samole 3 | sanely | 2013-11-27 17:37:00 | 2013-11-27 18:09:00 | 2013-11-27 09:37:42 | 1 | 20 |
+---------+----------+-------------+---------------------+---------------------+---------------------+--------+----------+
1 row in set (0.00 sec)
+---------+------------+---------+
| user_id | username | picture |
+---------+------------+---------+
| 1 | jamess2000 | NULL |
| 2 | yferna2012 | NULL |
+---------+------------+---------+
2 rows in set (0.00 sec)
+----------+------------------------------+---------------------+-------------+--------+
| addre_id | street | name | description | active |
+----------+------------------------------+---------------------+-------------+--------+
| 20 | Schieffelin | Manhattan Ville Loc | NULL | 1 |
+----------+------------------------------+---------------------+-------------+--------+
这里是我的Java代码片段
String SP_GET_EVENT_BY_ID = "CALL `events`.`get_event_by_id`(?)";
String PROC_PARAM_EVENT_ID = "evet_id";
mCallableStatement = mConnection.prepareCall(SP_GET_EVENT_BY_ID);
mCallableStatement.setInt(10, PROC_PARAM_EVENT_ID);
当我执行这个语句时,只有event_table的结果被返回。我使用以下方式来阅读查询:
ResultSet reader = mCallableStatement.executeQuery();
while(reader.next())
{
//etc..... here i assign db values to properties.
}
我试图避免多次向数据库发出请求,因为这非常慢(取决于结果数量,可能需要300毫秒)。
这是否可能实现?