Created
March 20, 2019 08:40
-
-
Save Manuri/a3847af4ac46c7e623527592e9a0ffc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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