Skip to content

Instantly share code, notes, and snippets.

@Manuri
Created March 20, 2019 08:40
Show Gist options
  • Save Manuri/a3847af4ac46c7e623527592e9a0ffc2 to your computer and use it in GitHub Desktop.
Save Manuri/a3847af4ac46c7e623527592e9a0ffc2 to your computer and use it in GitHub Desktop.
import ballerina/io;
import ballerinax/jdbc;
public type EmployeeOracle record {
string first_name;
string last_name;
float id;
float salary;
};
jdbc:Client testDB = new({
url: "jdbc:oracle:thin:@localhost:49161:xe",
username: "system",
password: "oracle",
poolOptions: { maximumPoolSize: 1 }
});
public function main() {
var dt1 = testDB->select("select * from employees", EmployeeOracle);
if (dt1 is table<EmployeeOracle>) {
foreach var entry in dt1 {
io:println(entry.id + "|" + entry.first_name + "|" + entry.last_name + "|" + entry.salary);
}
} else {
io:println(dt1.detail().message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment