protected final void enforceStatementProperties ( ) throws SQLException { // Synchronization not needed since this method will always be called from execute // methods which are already synchronized. // RRA does not support multithreaded access so synchronization is no // longer needed on the execute methods either. if ( requestedFetchSize != currentFetchSize ) { stmtImpl . setFetchSize ( requestedFetchSize ) ; currentFetchSize = requestedFetchSize ; } // Data source property syncQueryTimeoutWithTransactionTimeout indicates that we // should set the query timeout to equal the amount of time remaining in the JTA // transaction timeout, if a JTA transaction is active, and if no query timeout // has been programmatically set the by the user. if ( dsConfig . get ( ) . syncQueryTimeoutWithTransactionTimeout && ! queryTimeoutSetByUser ) { final boolean trace = TraceComponent . isAnyTracingEnabled ( ) ; // If in a JTA transaction, then set query timeout to time remaining in JTA transaction if ( ( ( WSJdbcConnection ) parentWrapper ) . managedConn . isGlobalTransactionActive ( ) ) { // Find out how much time remains in the JTA transaction timeout UOWManager uowmgr = UOWManagerFactory . getUOWManager ( ) ; long expireTime = uowmgr . getUOWExpiration ( ) ; long remainingTime = expireTime - System . currentTimeMillis ( ) ; if ( trace && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Milliseconds remaining in transaction timeout: " + remainingTime ) ; // Raise an error if the transaction should have already timed out. if ( remainingTime <= 0l ) throw new SQLTimeoutException ( "Transaction timeout " + ( - remainingTime ) + " ms ago." , "25000" ) ; // Invalid transaction state // Convert to seconds, rounding up remainingTime = ( remainingTime + 999l ) / 1000l ; // Track the previous value, in order to restore after transaction ends if ( queryTimeoutBeforeSync == null ) queryTimeoutBeforeSync = stmtImpl . getQueryTimeout ( ) ; if ( trace && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Setting query timeout to " + remainingTime ) ; stmtImpl . setQueryTimeout ( ( int ) remainingTime ) ; haveStatementPropertiesChanged = true ; } // If not in JTA transaction, then might need to restore to previous value else if ( queryTimeoutBeforeSync != null ) { if ( trace && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Restoring query timeout to " + queryTimeoutBeforeSync ) ; stmtImpl . setQueryTimeout ( queryTimeoutBeforeSync ) ; queryTimeoutBeforeSync = null ; } } }
Update statement properties before executing the statement . This method syncs the query timeout to the transaction timeout when appropriate and updates the current fetchSize according to the requested fetchSize value if needed . This method should be invoked before executing the statement .