Commit 6d0b78f0 authored by Quxl's avatar Quxl

x

parent 59b45fdf
...@@ -552,6 +552,51 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate { ...@@ -552,6 +552,51 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate {
}); });
} }
public List<Object> exec(final String sql, Map<Integer, Integer> out, final Object... args) {
showSql(sql, args);
return super.execute(new CallableStatementCreator() {
public CallableStatement createCallableStatement(final Connection con) throws SQLException {
final CallableStatement cs = con.prepareCall(sql);
for(int i = 0; i < args.length; i++) {
cs.setObject(i+1, args[i]);
}
if(out != null && out.size() > 0) {
for(Integer key : out.keySet()) {
cs.registerOutParameter(key, out.get(key));
}
}
return cs;
}
}, new CallableStatementCallback<List<Object>>() {
public List<Object> doInCallableStatement(final CallableStatement cs) throws SQLException, DataAccessException {
List<Object> datas = new ArrayList<Object>();
cs.execute();
while(true) {
Integer count = cs.getUpdateCount();
ResultSet resultSet = cs.getResultSet();
if(count == -1 && resultSet == null) {
break;
} else {
if(resultSet != null) {
datas.add(JUtil.resultSetToList(resultSet));
} else {
datas.add(count);
}
cs.getMoreResults();
}
}
Map<Integer, Object> outMap = new HashMap<Integer, Object>();
datas.add(outMap);
if(out != null && out.size() > 0) {
for(Integer key: out.keySet()) {
outMap.put(key, cs.getObject(key));
}
}
return datas;
}
});
}
public synchronized String getNumber(String... args) { public synchronized String getNumber(String... args) {
String sKey = null; String sKey = null;
String format = null; String format = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment