Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import ballerina/io;
  2. import ballerinax/jdbc;
  3.  
  4. public type EmployeeOracle record {
  5. string first_name;
  6. string last_name;
  7. float id;
  8. float salary;
  9. };
  10.  
  11. jdbc:Client testDB = new({
  12. url: "jdbc:oracle:thin:@localhost:49161:xe",
  13. username: "system",
  14. password: "oracle",
  15. poolOptions: { maximumPoolSize: 1 }
  16. });
  17.  
  18. public function main() {
  19. var dt1 = testDB->select("select * from employees", EmployeeOracle);
  20.  
  21. if (dt1 is table<EmployeeOracle>) {
  22. foreach var entry in dt1 {
  23. io:println(entry.id + "|" + entry.first_name + "|" + entry.last_name + "|" + entry.salary);
  24. }
  25. } else {
  26. io:println(dt1.detail().message);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement