Skip to content

Commit

Permalink
Fix #25
Browse files Browse the repository at this point in the history
  • Loading branch information
ccleve committed May 26, 2018
1 parent 0f33aca commit 78c8eed
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</developers>

<prerequisites>
<maven>3.0.4</maven>
<maven>3.3.9</maven>
</prerequisites>

<properties>
Expand Down
47 changes: 40 additions & 7 deletions src/main/java/com/dieselpoint/norm/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ public class Database {

private SqlMaker sqlMaker = new StandardSqlMaker();
private DataSource ds;

private String dataSourceClassName = System.getProperty("norm.dataSourceClassName");
private String driverClassName = System.getProperty("norm.driverClassName");
private String jdbcUrl = System.getProperty("norm.jdbcUrl");
private String serverName = System.getProperty("norm.serverName");
private String databaseName = System.getProperty("norm.databaseName");
private String user = System.getProperty("norm.user");
private String password = System.getProperty("norm.password");

/**
* Set the maker object for the particular flavor of sql.
Expand All @@ -38,25 +46,22 @@ protected DataSource getDataSource() throws SQLException {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(10);

String dataSourceClassName = System.getProperty("norm.dataSourceClassName");
if (dataSourceClassName != null) {
config.setDataSourceClassName(dataSourceClassName);
}

String driverClassName = System.getProperty("norm.driverClassName");
if (driverClassName != null) {
config.setDriverClassName(driverClassName);
}

String jdbcUrl = System.getProperty("norm.jdbcUrl");
if (jdbcUrl != null) {
config.setJdbcUrl(jdbcUrl);
}

addConfigProperty(config, "serverName", System.getProperty("norm.serverName"));
addConfigProperty(config, "databaseName", System.getProperty("norm.databaseName"));
addConfigProperty(config, "user", System.getProperty("norm.user"));
addConfigProperty(config, "password", System.getProperty("norm.password"));
addConfigProperty(config, "serverName", serverName);
addConfigProperty(config, "databaseName", databaseName);
addConfigProperty(config, "user", user);
addConfigProperty(config, "password", password);

return new HikariDataSource(config);
}
Expand Down Expand Up @@ -200,5 +205,33 @@ public Transaction startTransaction() {
public Query transaction(Transaction trans) {
return new Query(this).transaction(trans);
}

public void setDataSourceClassName(String dataSourceClassName) {
this.dataSourceClassName = dataSourceClassName;
}

public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}

public void setJdbcUrl(String jdbcUrl) {
this.jdbcUrl = jdbcUrl;
}

public void setServerName(String serverName) {
this.serverName = serverName;
}

public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}

public void setUser(String user) {
this.user = user;
}

public void setPassword(String password) {
this.password = password;
}

}
3 changes: 3 additions & 0 deletions src/test/java/com/dieselpoint/norm/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ public static void setSysProperties() {
System.setProperty("norm.password", "postgres");
*/




}
}

0 comments on commit 78c8eed

Please sign in to comment.