Commit 548a479d authored by R.W.Majeed's avatar R.W.Majeed

fixed bug in RunConfiguration causing postgres connection failure

parent a5ba9a5a
......@@ -22,27 +22,27 @@
<plugins>
<!-- plugins are loaded in order of occurance -->
<plugin class="de.sekmi.histream.i2b2.PostgresPatientStore">
<property name="user">i2b2demodata</property>
<property name="host">localhost</property>
<property name="database">i2b2</property>
<property name="port">15432</property>
<property name="password"></property>
<property name="jdbc.user">i2b2demodata</property>
<property name="jdbc.host">localhost</property>
<property name="jdbc.database">i2b2</property>
<property name="jdbc.port">15432</property>
<property name="jdbc.password"></property>
<property name="project">demo</property>
</plugin>
<plugin class="de.sekmi.histream.i2b2.PostgresVisitStore">
<property name="user">i2b2demodata</property>
<property name="host">localhost</property>
<property name="database">i2b2</property>
<property name="port">15432</property>
<property name="password"></property>
<property name="jdbc.user">i2b2demodata</property>
<property name="jdbc.host">localhost</property>
<property name="jdbc.database">i2b2</property>
<property name="jdbc.port">15432</property>
<property name="jdbc.password"></property>
<property name="project">demo</property>
</plugin>
<plugin class="de.sekmi.histream.i2b2.I2b2Inserter">
<property name="user">i2b2demodata</property>
<property name="host">localhost</property>
<property name="database">i2b2</property>
<property name="port">15432</property>
<property name="password"></property>
<property name="jdbc.user">i2b2demodata</property>
<property name="jdbc.host">localhost</property>
<property name="jdbc.database">i2b2</property>
<property name="jdbc.port">15432</property>
<property name="jdbc.password"></property>
<property name="project">demo</property>
<property name="nullProvider">LCS-I2B2:PROVIDERS</property>
</plugin>
......
......@@ -22,27 +22,27 @@
<plugins>
<!-- plugins are loaded in order of occurance -->
<plugin class="de.sekmi.histream.i2b2.PostgresPatientStore">
<property name="user">i2b2demodata</property>
<property name="host">localhost</property>
<property name="database">i2b2</property>
<property name="port">15432</property>
<property name="password"></property>
<property name="jdbc.user">i2b2demodata</property>
<property name="jdbc.host">localhost</property>
<property name="jdbc.database">i2b2</property>
<property name="jdbc.port">15432</property>
<property name="jdbc.password"></property>
<property name="project">demo</property>
</plugin>
<plugin class="de.sekmi.histream.i2b2.PostgresVisitStore">
<property name="user">i2b2demodata</property>
<property name="host">localhost</property>
<property name="database">i2b2</property>
<property name="port">15432</property>
<property name="password"></property>
<property name="jdbc.user">i2b2demodata</property>
<property name="jdbc.host">localhost</property>
<property name="jdbc.database">i2b2</property>
<property name="jdbc.port">15432</property>
<property name="jdbc.password"></property>
<property name="project">demo</property>
</plugin>
<plugin class="de.sekmi.histream.i2b2.I2b2Inserter">
<property name="user">i2b2demodata</property>
<property name="host">localhost</property>
<property name="database">i2b2</property>
<property name="port">15432</property>
<property name="password"></property>
<property name="jdbc.user">i2b2demodata</property>
<property name="jdbc.host">localhost</property>
<property name="jdbc.database">i2b2</property>
<property name="jdbc.port">15432</property>
<property name="jdbc.password"></property>
<property name="project">demo</property>
<property name="nullProvider">LCS-I2B2:PROVIDERS</property>
</plugin>
......
......@@ -160,15 +160,17 @@ public class RunConfiguration implements Closeable{
return version;
}
public static void main(String args[])throws Exception{
/*
if( System.console() == null ){
JOptionPane.showMessageDialog(null, "This program should be run with a console", "HIStream "+readVersion(), JOptionPane.WARNING_MESSAGE);
return;
}
}*/
// TODO check for file histream.xml
File xml = new File("histream.xml");
if( !xml.canRead() ){
System.err.println("Unable to find/read file histream.xml");
xml = new File("src/test/resources/histream.xml");
xml = new File("examples/histream.xml");
if( xml.canRead() )
System.err.println("Using src/test/resources/histream.xml");
else
......
......@@ -27,6 +27,7 @@ import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import de.sekmi.histream.DateTimeAccuracy;
......@@ -62,7 +63,22 @@ public abstract class PostgresExtension<T> implements Extension<T>, Plugin {
private static Connection getConnection(Properties props) throws SQLException, ClassNotFoundException{
Class.forName(driver);
return DriverManager.getConnection("jdbc:postgresql://"+props.get("host")+":"+props.get("port")+"/"+props.get("database"), props);
StringBuilder sb = new StringBuilder("jdbc:postgresql://");
if( props.get("host") == null ){
throw new IllegalArgumentException("host property missing for JDBC connection");
}else{
sb.append(props.get("host"));
}
if( props.get("port") != null ){
sb.append(':').append(props.get("port"));
}
if( !props.containsKey("database") ){
throw new IllegalArgumentException("database property missing for JDBC connection");
}
sb.append('/').append(props.getProperty("database"));
return DriverManager.getConnection(sb.toString(), props);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment