Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2004 - 2011 Brian McCallister
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.skife.jdbi.v2;
 
 
 
 public final class StatementCustomizers
 {
     private StatementCustomizers()
     {
     }

    
Hint to the statement, that we want only a single row. Used by Query.first() to limit the number of rows returned by the database.
 
     public static final StatementCustomizer MAX_ROW_ONE = new MaxRowsCustomizer(1);

    
Sets the fetch direction on a query. Can be used as a Statement customizer or a SqlStatementCustomizer.
 
     public static class FetchDirectionStatementCustomizer extends BaseStatementCustomizer
     {
         private final Integer direction;
 
         public FetchDirectionStatementCustomizer(final Integer direction)
         {
             this. = direction;
         }
 
         @Override
         public void beforeExecution(final PreparedStatement stmtfinal StatementContext ctxthrows SQLException
         {
             stmt.setFetchDirection();
         }
 
         public void apply(SQLStatement qthrows SQLException
         {
             q.setFetchDirection();
         }
     }
 
     public static final class QueryTimeoutCustomizer extends BaseStatementCustomizer
     {
         private final int seconds;
 
         public QueryTimeoutCustomizer(final int seconds)
         {
             this. = seconds;
         }
 
         @Override
         public void beforeExecution(final PreparedStatement stmtfinal StatementContext ctxthrows SQLException
         {
             stmt.setQueryTimeout();
         }
     }
 
     public static final class FetchSizeCustomizer extends BaseStatementCustomizer
     {
         private final int fetchSize;
 
         public FetchSizeCustomizer(final int fetchSize)
         {
             this. = fetchSize;
         }
 
         @Override
         public void beforeExecution(final PreparedStatement stmtfinal StatementContext ctxthrows SQLException
         {
             stmt.setFetchSize();
         }
     }
 
     public static final class MaxRowsCustomizer extends BaseStatementCustomizer
     {
         private final int maxRows;
 
         public MaxRowsCustomizer(final int maxRows)
         {
             this. = maxRows;
        }
        @Override
        public void beforeExecution(final PreparedStatement stmtfinal StatementContext ctxthrows SQLException
        {
            stmt.setMaxRows();
        }
    }
    public static final class MaxFieldSizeCustomizer extends BaseStatementCustomizer
    {
        private final int maxFieldSize;
        public MaxFieldSizeCustomizer(final int maxFieldSize)
        {
            this. = maxFieldSize;
        }
        @Override
        public void beforeExecution(final PreparedStatement stmtfinal StatementContext ctxthrows SQLException
        {
            stmt.setMaxFieldSize();
        }
    }
New to GrepCode? Check out our FAQ X