parent
349337ddf6
commit
74e5c8fe8d
@ -0,0 +1,21 @@
|
|||||||
|
package space.kklochko.jdbc_hospital_example.db.factories;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
|
import space.kklochko.jdbc_hospital_example.config.models.DataBaseConfig;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
public class DataBaseConnection extends DataBaseConnectionFactory {
|
||||||
|
private DataBaseConfig dbConfig;
|
||||||
|
|
||||||
|
public DataBaseConnection(DataBaseConfig dbConfig) {
|
||||||
|
setDbConfig(dbConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection connect() throws SQLException {
|
||||||
|
return DriverManager.getConnection(dbConfig.getUrl(), dbConfig.getProperties());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package space.kklochko.jdbc_hospital_example.db.factories;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public abstract class DataBaseConnectionFactory {
|
||||||
|
abstract public Connection connect() throws SQLException;
|
||||||
|
}
|
Loading…
Reference in new issue