Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. package org.openmrs.api.example;
  2.  
  3. import org.openmrs.Patient;
  4. import org.openmrs.util.DatabaseUpdateException;
  5. import org.openmrs.util.InputRequiredException;
  6. import org.openmrs.util.OpenmrsUtil;
  7.  
  8. import java.io.File;
  9. import java.io.FileInputStream;
  10. import java.io.FileNotFoundException;
  11. import java.util.List;
  12. import java.util.Properties;
  13. import org.openmrs.User;
  14.  
  15. import static org.openmrs.api.context.Context.*;
  16. import static org.openmrs.api.context.Context.closeSession;
  17. import static org.openmrs.util.OpenmrsUtil.loadProperties;
  18.  
  19. public class Example {
  20. public static void main(String[] args) throws FileNotFoundException, InputRequiredException, DatabaseUpdateException {
  21. File propsFile = new File("C:\\Users\\The Bright\\openmrs\\server1", "openmrs-runtime.properties");
  22. Properties props = new Properties();
  23. loadProperties(props, new FileInputStream(propsFile));
  24. //System.out.println(props);
  25. startup("jdbc:mysql://127.0.0.1:3306/server2?autoReconnect=true", "root", "root", props);
  26. try {
  27. openSession();
  28. authenticate("admin", "Admin123");
  29. List<User> users = getUserService().getAllUsers();
  30. for (User usr : users) {
  31. System.out.println("Found patient with name " + usr.getPersonName() + " and uuid: " + usr.getUuid());
  32. }
  33. } finally {
  34. closeSession();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement