sql refactoring

This commit is contained in:
Roman Zhuravlev 2023-08-11 19:37:21 +05:00
parent 9b20d7c8cd
commit 4ce0f36193

View file

@ -0,0 +1,23 @@
package org.zhdev.varioutil.sql;
import java.sql.Connection;
import java.sql.SQLException;
public interface ConnectionProvider {
ConnectionProvider NOT_ESTABLISHED = new NullProvider("Connection not established");
ConnectionProvider CLOSED = new NullProvider("Connection closed");
Connection getConnection();
default boolean isClosed() {
return true;
}
default void close() {
try {
getConnection().close();
} catch (SQLException e) {
throw new SqlException(e);
}
}
}