Commit 8a3ecbb9 authored by 张永's avatar 张永

Merge branch 'master' of http://gitlab.egolm.com/key/common.git

parents 2a4fe134 bb6dbc52
...@@ -10,6 +10,7 @@ import java.io.UnsupportedEncodingException; ...@@ -10,6 +10,7 @@ import java.io.UnsupportedEncodingException;
import java.io.Writer; import java.io.Writer;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
...@@ -1137,4 +1138,9 @@ public class StringUtil { ...@@ -1137,4 +1138,9 @@ public class StringUtil {
return filePath.matches("^.+\\.(?i)(xlsx)$"); return filePath.matches("^.+\\.(?i)(xlsx)$");
} }
public static String getRandomNum(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
return sdf.format(new Date())+StringUtil.getRandom(4);
}
} }
...@@ -519,6 +519,39 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate { ...@@ -519,6 +519,39 @@ public class JdbcTemplate extends org.springframework.jdbc.core.JdbcTemplate {
}); });
} }
public List<Object> exec(final String sql, 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]);
}
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();
}
}
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