org.postgresql.replication.fluent.physical.PhysicalCreateSlotBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of postgresql Show documentation
Show all versions of postgresql Show documentation
Java JDBC 4.2 (JRE 8+) driver for PostgreSQL database
/*
* Copyright (c) 2016, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
package org.postgresql.replication.fluent.physical;
import org.postgresql.core.BaseConnection;
import org.postgresql.replication.fluent.AbstractCreateSlotBuilder;
import java.sql.SQLException;
import java.sql.Statement;
public class PhysicalCreateSlotBuilder
extends AbstractCreateSlotBuilder
implements ChainedPhysicalCreateSlotBuilder {
private BaseConnection connection;
public PhysicalCreateSlotBuilder(BaseConnection connection) {
this.connection = connection;
}
@Override
protected ChainedPhysicalCreateSlotBuilder self() {
return this;
}
@Override
public void make() throws SQLException {
if (slotName == null || slotName.isEmpty()) {
throw new IllegalArgumentException("Replication slotName can't be null");
}
Statement statement = connection.createStatement();
try {
statement.execute(String.format("CREATE_REPLICATION_SLOT %s PHYSICAL", slotName));
} finally {
statement.close();
}
}
}