Guest User

Untitled

a guest
Sep 23rd, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import ballerina/io;
  2. import ballerina/jdbc;
  3.  
  4. // Client endpoint for MySQL database.
  5. endpoint jdbc:Client testDB {
  6. url: "jdbc:mysql://localhost:3306/testdb",
  7. username: "test",
  8. password: "test",
  9. poolOptions: { maximumPoolSize: 5 },
  10. dbOptions: { useSSL: false }
  11. };
  12.  
  13. // This is the type created to represent data row.
  14. type Student record {
  15. int id;
  16. int age;
  17. string name;
  18. };
  19.  
  20. public function main() {
  21. table<Student> t1 = check testDB->select("SELECT * from student", Student, loadToMemory=true);
  22. foreach s in t1 {
  23. io:println(s);
  24. }
  25. testDB.stop();
  26. }
Add Comment
Please, Sign In to add comment