All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.database.PreparedStatementFactory Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
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 + "]";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy