sql refactoring
This commit is contained in:
parent
9b20d7c8cd
commit
4ce0f36193
1 changed files with 23 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue