Hi, @tendomart @danfuterman @dkayiwa @darius
I am using ubuntu . I have installed bahmni in vagrant .I want to connect vagrant bahmni to our java code
import java.io.File;
import java.util.List;
import java.util.Properties;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
import org.openmrs.module.ModuleMustStartException;
import org.openmrs.util.DatabaseUpdateException;
import org.openmrs.util.InputRequiredException;
import org.openmrs.util.OpenmrsUtil;
public class Test {
public static void main(String[] args) {
File propsFile = new File(OpenmrsUtil.getApplicationDataDirectory(), "openmrs-runtime.properties");
Properties props = new Properties();
OpenmrsUtil.loadProperties(props, propsFile);
System.out.println(props+" "+propsFile);
try {
Context.startup("jdbc:mysql://192.168.0.172/openmrs?autoReconnect=true", "uopenmrs", "openmrs", props);
} catch (ModuleMustStartException | DatabaseUpdateException | InputRequiredException e) {
System.out.println("----------------------"+props);
e.printStackTrace();
}
try {
Context.openSession();
Context.authenticate("superman", "Admin123");
System.out.println("govind run");
List<Patient> patients = Context.getPatientService().getPatients("govind");
for (Patient patient : patients) {
System.out.println("Found patient with name " + patient.getPersonName() + " and uuid: " + patient.getUuid());
}
}
finally {
Context.closeSession();
}
}
}
----------------------------------------Getting Eror In Console Eclipse---------------------------------------
- PropertyFile :/home/tattva/.OpenMRS/openmrs-runtime.properties
- {encryption.vector=fXAGMx/ziLvlbUvqN0XFmw==, module.allow_web_admin=true, connection.url=jdbc:mysql://localhost:3306/openmrs?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8, connection.username=openmrs_user, encryption.key=9qQItDyCFsfRYTZIFO4GAw==, auto_update_database=false, connection.password=5GG0ltTcddG@} /home/tattva/.OpenMRS/openmrs-runtime.properties
- Strup :username uopenmrs
- password openmrs
- properties jdbc:mysql://192.168.0.172/openmrs?autoReconnect=truenull
- null
- null
- log4j:WARN No appenders could be found for logger (org.openmrs.api.context.Context).
- log4j:WARN Please initialize the log4j system properly.
- Exception in thread “main” org.openmrs.api.APIException: contextDAO is null
- at org.openmrs.api.context.Context.getContextDAO(Context.java:162)
- at org.openmrs.api.context.Context.openSession(Context.java:740)
- at org.openmrs.api.context.Context.startup(Context.java:904)
- at Test.main(Test.java:20) [/poll]