private int executeCallableStatement(final String aSql, final Integer fetchSize, QueryListener queryListener) throws SQLException {
if(isNotConnected()){
try{
queryListener.onError("DB연결을 먼저하세요!!");
}
finally{
queryListener.onFinished();
}
return 0;
}
final String sql = trimSqlErrorString(aSql);
int rownums=0;
ResultSet rset = null;
CallableStatement stmt = null;//ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
try{
stmt = connMgr.prepareCall(sql);
stmt.execute();
queryListener.onEachQueryExecuting(stmt);
if(stmt.getMoreResults()){
rset = stmt.getResultSet();
rownums = queryListener.onEachResultSet(sql, rset, fetchSize);
}
else {
rownums = stmt.getUpdateCount();
queryListener.onUpdatedCount(rownums, sql);
}
}
finally{
connMgr.close(rset, stmt);
queryListener.onEachQueryClosed();
}
return rownums;
}
private String trimSqlErrorString(String aSql) {
//.replaceAll("--[^\n]+\n", "").replaceAll("/\\*[^/]+\\*/", "").replaceAll("\\?","'1'").trim();
return MyStringUtil.trim(aSql).replaceAll("/\\*\\s+", "/*");
}