/** * Return the prepared statement with the given identifier; first looks in the statement cache and if it does * not exist there create a new statement. This method is used for building statements with variable argument * numbers (e.g. in an IN). * * @param key the id of the statement in statements.properties * @param numberOfArguments the number of arguments for the prepared statement * @return the PreparedStatement * @throws SQLException */ public PreparedStatement getPreparedStatement(String key, int numberOfArguments) throws SQLException { requireJDBCConnection(); PreparedStatement statement = statementCache.get(key+numberOfArguments); if (statement == null || statement.isClosed()) { StringBuilder s = new StringBuilder(); for(int i=0; i<numberOfArguments; i++) { if(i != 0) { s.append(','); } s.append('?'); } statement = connection.prepareStatement(String.format(dialect.getStatement(key),s.toString(), numberOfArguments), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statementCache.put(key+numberOfArguments,statement); } statement.clearParameters(); if(persistence.getDialect().isCursorSupported()) { statement.setFetchSize(persistence.getConfiguration().getCursorSize()); } return statement; }
/** * Return the prepared statement with the given identifier; first looks in the statement cache and if it does * not exist there create a new statement. This method is used for building statements with variable argument * numbers (e.g. in an IN). * * @param key the id of the statement in statements.properties * @param numberOfArguments the number of arguments for the prepared statement * @return the PreparedStatement * @throws SQLException */ public PreparedStatement getPreparedStatement(String key, int numberOfArguments) throws SQLException { requireJDBCConnection(); PreparedStatement statement = statementCache.get(key+numberOfArguments); if (statement == null || statement.isClosed()) { StringBuilder s = new StringBuilder(); for(int i=0; i<numberOfArguments; i++) { if(i != 0) { s.append(','); } s.append('?'); } statement = connection.prepareStatement(String.format(dialect.getStatement(key),s.toString(), numberOfArguments), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statementCache.put(key+numberOfArguments,statement); } statement.clearParameters(); if(persistence.getDialect().isCursorSupported()) { statement.setFetchSize(persistence.getConfiguration().getCursorSize()); } return statement; }
/** * Return the prepared statement with the given identifier; first looks in the statement cache and if it does * not exist there create a new statement. * * @param key the id of the statement in statements.properties * @return the PreparedStatement * @throws SQLException */ public PreparedStatement getPreparedStatement(String key) throws SQLException { requireJDBCConnection(); PreparedStatement statement = statementCache.get(key); if (statement == null || statement.isClosed()) { statement = connection.prepareStatement(dialect.getStatement(key), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statementCache.put(key,statement); } statement.clearParameters(); if (persistence.getDialect().isCursorSupported()) { statement.setFetchSize(persistence.getConfiguration().getCursorSize()); } return statement; }
/** * Return the prepared statement with the given identifier; first looks in the statement cache and if it does * not exist there create a new statement. * * @param key the id of the statement in statements.properties * @return the PreparedStatement * @throws SQLException */ public PreparedStatement getPreparedStatement(String key) throws SQLException { requireJDBCConnection(); PreparedStatement statement = statementCache.get(key); if (statement == null || statement.isClosed()) { statement = connection.prepareStatement(dialect.getStatement(key), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statementCache.put(key,statement); } statement.clearParameters(); if (persistence.getDialect().isCursorSupported()) { statement.setFetchSize(persistence.getConfiguration().getCursorSize()); } return statement; }
queryStatement.setFetchSize(connection.getConfiguration().getCursorSize());
query.setFetchSize(persistence.getConfiguration().getCursorSize());
query.setFetchSize(persistence.getConfiguration().getCursorSize());