Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ballerina/io;
- import ballerina/jdbc;
- // Client endpoint for MySQL database.
- endpoint jdbc:Client testDB {
- url: "jdbc:mysql://localhost:3306/testdb",
- username: "test",
- password: "test",
- poolOptions: { maximumPoolSize: 5 },
- dbOptions: { useSSL: false }
- };
- // This is the type created to represent data row.
- type Student record {
- int id;
- int age;
- string name;
- };
- public function main() {
- table<Student> t1 = check testDB->select("SELECT * from student", Student, loadToMemory=true);
- foreach s in t1 {
- io:println(s);
- }
- testDB.stop();
- }
Add Comment
Please, Sign In to add comment