List of usage examples for java.sql CallableStatement setMaxRows
void setMaxRows(int max) throws SQLException;
ResultSet
object generated by this Statement
object can contain to the given number. From source file:nl.nn.adapterframework.jdbc.JdbcQuerySenderBase.java
protected String executePackageQuery(Connection connection, PreparedStatement statement, String message) throws SenderException, JdbcException, IOException, JMSException { Object[] paramArray = new Object[10]; String callMessage = fillParamArray(paramArray, message); ResultSet resultset = null;/*from w ww .j av a 2 s . co m*/ try { CallableStatement pstmt = connection.prepareCall(callMessage); if (getMaxRows() > 0) { pstmt.setMaxRows(getMaxRows() + (getStartRow() > 1 ? getStartRow() - 1 : 0)); } int var = 1; for (int i = 0; i < paramArray.length; i++) { if (paramArray[i] instanceof Timestamp) { pstmt.setTimestamp(var, (Timestamp) paramArray[i]); var++; } if (paramArray[i] instanceof java.sql.Date) { pstmt.setDate(var, (java.sql.Date) paramArray[i]); var++; } if (paramArray[i] instanceof String) { pstmt.setString(var, (String) paramArray[i]); var++; } if (paramArray[i] instanceof Integer) { int x = Integer.parseInt(paramArray[i].toString()); pstmt.setInt(var, x); var++; } if (paramArray[i] instanceof Float) { float x = Float.parseFloat(paramArray[i].toString()); pstmt.setFloat(var, x); var++; } } if (message.indexOf('?') != -1) { pstmt.registerOutParameter(var, Types.CLOB); // make sure enough space is available for result... } if ("xml".equalsIgnoreCase(getPackageContent())) { log.debug(getLogPrefix() + "executing a package SQL command"); pstmt.executeUpdate(); String pUitvoer = pstmt.getString(var); return pUitvoer; } log.debug(getLogPrefix() + "executing a package SQL command"); int numRowsAffected = pstmt.executeUpdate(); if (StringUtils.isNotEmpty(getResultQuery())) { Statement resStmt = null; try { resStmt = connection.createStatement(); log.debug("obtaining result from [" + getResultQuery() + "]"); ResultSet rs = resStmt.executeQuery(getResultQuery()); return getResult(rs); } finally { if (resStmt != null) { resStmt.close(); } } } if (getColumnsReturnedList() != null) { return getResult(getReturnedColumns(getColumnsReturnedList(), statement)); } if (isScalar()) { return numRowsAffected + ""; } return "<result><rowsupdated>" + numRowsAffected + "</rowsupdated></result>"; } catch (SQLException sqle) { throw new SenderException(getLogPrefix() + "got exception executing a package SQL command", sqle); } finally { try { if (resultset != null) { resultset.close(); } } catch (SQLException e) { log.warn(new SenderException(getLogPrefix() + "got exception closing resultset", e)); } } }