Skip to content

Commit fbface4

Browse files
author
Igor Polevoy
committed
#417 - added database.properties file name as default, without a need for activejdbc.properties file
1 parent 2a3d08e commit fbface4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

activejdbc/src/main/java/org/javalite/activejdbc/Configuration.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ protected Configuration(){
107107

108108
private void loadConnectionsSpecs() {
109109
try{
110-
Properties connectionProps = readPropertyFile(properties.getProperty("env.connections.file"));
110+
111+
String propertyFileName = properties == null ? "database.properties"
112+
: properties.getProperty("env.connections.file", "database.properties");
113+
114+
Properties connectionProps = readPropertyFile(propertyFileName);
111115
for (String env : getEnvironments(connectionProps)) {
112116
String jndiName = env + "." + "jndi";
113117
if (connectionProps.containsKey(jndiName)) {
@@ -143,9 +147,11 @@ private Set<String> getEnvironments(Properties props) {
143147
return new TreeSet<String>(environments);
144148
}
145149

146-
//read from classpath, if not found, fead from file system. If not found there, throw exception
150+
//read from classpath, if not found, read from file system. If not found there, throw exception
147151
private Properties readPropertyFile(String file) throws IOException {
148-
InputStream in = getClass().getResourceAsStream(file);
152+
153+
String fileName = file.startsWith("/") ? file : "/" + file;
154+
InputStream in = getClass().getResourceAsStream(fileName);
149155
Properties props = new Properties();
150156
if (in != null) {
151157
props.load(in);

0 commit comments

Comments
 (0)