liquibase.database.PreparedStatementFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase.database;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import java.sql.PreparedStatement;
/**
* Factory for PreparedStatements
*/
public final class PreparedStatementFactory {
private final JdbcConnection con;
public PreparedStatementFactory(JdbcConnection con) {
if(con == null) throw new IllegalArgumentException("connection must not be null");
this.con = con;
}
/**
* Creates a PreparedStatement
object for the specified SQL statement.
* The SQL statement may be pre-compiled by the driver depending on its support.
*
* @param sql the SQL statement to execute
* @return a PreparedStatement
object representing the specified SQL statement
* @throws DatabaseException if a database access error occurs or the given SQL statement is invalid
*/
public PreparedStatement create(String sql) throws DatabaseException {
return con.prepareStatement(sql);
}
@Override
public String toString() {
return "[con: " + con + "]";
}
}