diff --git a/src/main/java/com/cubetiqs/sql/ConnectionFactory.java b/src/main/java/com/cubetiqs/sql/ConnectionFactory.java index 5c0c288..8444f64 100644 --- a/src/main/java/com/cubetiqs/sql/ConnectionFactory.java +++ b/src/main/java/com/cubetiqs/sql/ConnectionFactory.java @@ -6,6 +6,7 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; +import java.util.Properties; import java.util.logging.Logger; public final class ConnectionFactory { @@ -15,6 +16,8 @@ public final class ConnectionFactory { private String user; private String password; + private Properties info; + public ConnectionBuilder driver(String driver) { this.driver = driver; return this; @@ -35,11 +38,22 @@ public final class ConnectionFactory { return this; } + public ConnectionBuilder info(Properties info) { + this.info = info; + return this; + } + public ConnectionBuilder properties(DataSourceProps properties) { - this.driver = properties.getDriver(); - this.url = properties.getUrl(); - this.user = properties.getUser(); - this.password = properties.getPassword(); + if (properties != null) { + this.driver = properties.getDriver(); + this.url = properties.getUrl(); + this.user = properties.getUser(); + this.password = properties.getPassword(); + if (properties.getProperties() != null && !properties.getProperties().isEmpty()) { + this.info = new Properties(); + this.info.putAll(properties.getProperties()); + } + } return this; } @@ -55,6 +69,10 @@ public final class ConnectionFactory { } if (user == null && password == null) { + if (info != null) { + return DriverManager.getConnection(url, info); + } + return DriverManager.getConnection(url); }