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;
A StatementBuilder which will always create a new PreparedStatement
public class DefaultStatementBuilder implements StatementBuilder
{
    
Create a new DefaultStatementBuilder which will always create a new PreparedStatement from the Connection

Parameters:
conn Used to prepare the statement
sql Translated SQL statement
ctx Unused
Returns:
a new PreparedStatement
    public PreparedStatement create(Connection connString sqlStatementContext ctxthrows SQLException
    {
        if (ctx.isReturningGeneratedKeys()) {
            return conn.prepareStatement(sql.);
        }
        else {
            return conn.prepareStatement(sql);
        }
    }

    
Called to close an individual prepared statement created from this builder. In this case, it closes imemdiately

Parameters:
sql the translated SQL which was prepared
stmt the statement
Throws:
java.sql.SQLException if anything goes wrong closing the statement
    public void close(Connection connString sqlStatement stmtthrows SQLException
    {
        if (stmt != nullstmt.close();
    }

    
In this case, a NOOP
    public void close(Connection conn)
    {
    }

Called each time a Callable statement needs to be created

Parameters:
conn the JDBC Connection the statement is being created for
sql the translated SQL which should be prepared
ctx Statement context associated with the SQLStatement this is building for
	{
		return conn.prepareCall(sql);
	}
New to GrepCode? Check out our FAQ X