From 88904abf48dd67175904cf4a4ba86d2a7d6cffe9 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Fri, 3 Dec 2021 10:37:50 +0530 Subject: [PATCH 1/5] Initialize OracleDB driver library --- .github/CODEOWNERS | 7 +++ .github/ISSUE_TEMPLATE/type_bug.md | 24 ++++++++ .github/ISSUE_TEMPLATE/type_improvement.md | 22 ++++++++ .github/ISSUE_TEMPLATE/type_new_feature.md | 22 ++++++++ .github/ISSUE_TEMPLATE/type_task.md | 20 +++++++ .github/workflows/ci.yml | 23 ++++++++ .github/workflows/release.yml | 25 +++++++++ .github/workflows/stale-check.yml | 19 +++++++ .gitignore | 22 ++++++++ Ballerina.toml | 24 ++++++++ Package.md | 29 ++++++++++ README.md | 47 +++++++++++++++- client.bal | 16 ++++++ tests/connection-init.bal | 65 ++++++++++++++++++++++ 14 files changed, 363 insertions(+), 2 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/type_bug.md create mode 100644 .github/ISSUE_TEMPLATE/type_improvement.md create mode 100644 .github/ISSUE_TEMPLATE/type_new_feature.md create mode 100644 .github/ISSUE_TEMPLATE/type_task.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/stale-check.yml create mode 100644 Ballerina.toml create mode 100644 Package.md create mode 100644 client.bal create mode 100644 tests/connection-init.bal diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..5fb573f --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +# Lines starting with '#' are comments. +# Each line is a file pattern followed by one or more owners. + +# See: https://help.github.com/articles/about-codeowners/ + +# These owners will be the default owners for everything in the repo. +* @daneshk @niveathika @kaneeldias diff --git a/.github/ISSUE_TEMPLATE/type_bug.md b/.github/ISSUE_TEMPLATE/type_bug.md new file mode 100644 index 0000000..b14deab --- /dev/null +++ b/.github/ISSUE_TEMPLATE/type_bug.md @@ -0,0 +1,24 @@ +--- +name: "Bug Report" +about: "Report a bug if something is not working as expected" +labels: 'Type/Bug' + +--- + +**Description:** + + +**Steps to reproduce:** + +**Affected Versions:** + +**OS, DB, other environment details and versions:** + +**Related Issues (optional):** + + +**Suggested Labels (optional):** + + +**Suggested Assignees (optional):** + diff --git a/.github/ISSUE_TEMPLATE/type_improvement.md b/.github/ISSUE_TEMPLATE/type_improvement.md new file mode 100644 index 0000000..c7af370 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/type_improvement.md @@ -0,0 +1,22 @@ +--- +name: "Improvement Request" +about: "Create an improvement request for an existing feature" +labels: 'Type/Improvement' + +--- + +**Description:** + + +**Describe your problem(s)** + +**Describe your solution(s)** + +**Related Issues (optional):** + + +**Suggested Labels (optional):** + + +**Suggested Assignees (optional):** + diff --git a/.github/ISSUE_TEMPLATE/type_new_feature.md b/.github/ISSUE_TEMPLATE/type_new_feature.md new file mode 100644 index 0000000..72c00df --- /dev/null +++ b/.github/ISSUE_TEMPLATE/type_new_feature.md @@ -0,0 +1,22 @@ +--- +name: "New Feature Request" +about: "Create a new feature request" +labels: 'Type/NewFeature' + +--- + +**Description:** + + +**Describe your problem(s)** + +**Describe your solution(s)** + +**Related Issues (optional):** + + +**Suggested Labels (optional):** + + +**Suggested Assignees (optional):** + diff --git a/.github/ISSUE_TEMPLATE/type_task.md b/.github/ISSUE_TEMPLATE/type_task.md new file mode 100644 index 0000000..2cc8fbe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/type_task.md @@ -0,0 +1,20 @@ +--- +name: "Task" +about: "Create a task which you want to keep track" +labels: 'Type/Task' + +--- + +**Description:** + + +**Describe your task(s)** + +**Related Issues (optional):** + + +**Suggested Labels (optional):** + + +**Suggested Assignees (optional):** + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c5dc8fb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: + - main + workflow_dispatch: + pull_request: + branches: + - main + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Ballerina Build + uses: ballerina-platform/ballerina-action/@slbeta5 + with: + args: + build -c --skip-tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..abf6964 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Deployment + +on: + release: + types: [published] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Ballerina Build + uses: ballerina-platform/ballerina-action/@slbeta5 + with: + args: + build -c --skip-tests + - name: Ballerina Push + uses: ballerina-platform/ballerina-action/@slbeta5 + with: + args: + push + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} diff --git a/.github/workflows/stale-check.yml b/.github/workflows/stale-check.yml new file mode 100644 index 0000000..9f487da --- /dev/null +++ b/.github/workflows/stale-check.yml @@ -0,0 +1,19 @@ +name: 'Close stale pull requests' + +on: + schedule: + - cron: '30 19 * * *' + workflow_dispatch: + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + stale-pr-message: 'This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the `stale` label is removed or commented.' + close-pr-message: 'Closed PR due to inactivity for more than 18 days.' + days-before-pr-stale: 15 + days-before-pr-close: 3 + days-before-issue-stale: -1 + days-before-issue-close: -1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index a1c2a23..4117d71 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,25 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# Target folder of ballerina project +/target/* + +# resources folder +/resources/* + +# idea files +*.idea +*.iml + +# .ballerina files +*.ballerina + +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build + +# +*.log \ No newline at end of file diff --git a/Ballerina.toml b/Ballerina.toml new file mode 100644 index 0000000..409cadd --- /dev/null +++ b/Ballerina.toml @@ -0,0 +1,24 @@ +[package] +org="ballerinax" +name="oracledb.driver" +version="1.2.0" +authors=["Ballerina"] +keywords=["OracleDB"] +repository="https://github.com/ballerina-platform/module-ballerinax-oracledb.driver" +license=["Apache-2.0"] +distribution = "slbeta5" + +[[platform.java11.dependency]] +groupId = "com.oracle.database.jdbc" +artifactId = "ojdbc8" +version = "21.3.0.0" + +[[platform.java11.dependency]] +groupId = "com.oracle.database.xml" +artifactId = "xdb" +version = "21.3.0.0" + +[[platform.java11.dependency]] +groupId = "com.oracle.database.xml" +artifactId = "xmlparserv2" +version = "12.2.0.1" diff --git a/Package.md b/Package.md new file mode 100644 index 0000000..b66bb3f --- /dev/null +++ b/Package.md @@ -0,0 +1,29 @@ +## Package overview + +This Package bundles the latest OracleDB drivers so that the OracleDB connector can be used in ballerina projects easily. + +## Compatibility + +| | Version | +|:---|:---:| +|Ballerina Language | **Swan Lake Beta 5** | +|OracleDB Driver | **21.3.0.0** | +|XDB | **21.3.0.0** | +|Xmlparserv2 | **21.3.0.0** | + + +> The above are released under the [Oracle Free Use Terms and Conditions](https://www.oracle.com/downloads/licenses/oracle-free-license.html). + +## Usage + +To add the OracleDB driver dependency the project, simply import the module as below, + +```ballerina +import ballerina/sql; +import ballerinax/oracledb; +import ballerinax/oracledb.driver as _; +``` + +# Useful Links +* Chat live with us via our [Slack channel](https://ballerina.io/community/slack/). +* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. diff --git a/README.md b/README.md index 9875c62..dfa9253 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ -# module-ballerinax-oracledb.driver -OracleDB driver package for Ballerina +Ballerina OracleDB Driver Library +=================== + +The OracleDB Driver library is one of the external library packages of the Ballerina language. + +This Package bundles the latest OracleDB drivers so that the OracleDB connector can be used in ballerina projects easily. + + # Building from the Source + ## Setting Up the Prerequisites + + 1. Download and install Java SE Development Kit (JDK) version 11 (from one of the following locations). + + * [Oracle](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) + + * [OpenJDK](https://adoptopenjdk.net/) + + > **Note:** Set the JAVA_HOME environment variable to the path name of the directory into which you installed JDK. + + 2. Download and install [Ballerina SL Beta 5](https://ballerina.io/). + + ## Building the Source + + Execute the commands below to build from the source after installing Ballerina Swan Lake Beta 5 version. + + 1. To build the library: + ```shell script + bal build + ``` + + 2. To build the module without the tests: + ```shell script + bal build --skip-tests + ``` + # Contributing to Ballerina + As an open source project, Ballerina welcomes contributions from the community. + + For more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/main/CONTRIBUTING.md). + + # Code of Conduct + All contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct). + + # Useful Links + * Chat live with us via our [Slack channel](https://ballerina.io/community/slack/). + * Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. diff --git a/client.bal b/client.bal new file mode 100644 index 0000000..9646732 --- /dev/null +++ b/client.bal @@ -0,0 +1,16 @@ +// Copyright (c) 2021 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// +// WSO2 Inc. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + diff --git a/tests/connection-init.bal b/tests/connection-init.bal new file mode 100644 index 0000000..f03b71b --- /dev/null +++ b/tests/connection-init.bal @@ -0,0 +1,65 @@ +// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + +// WSO2 Inc. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/sql; +import ballerinax/java.jdbc; +import ballerina/test; + +string url = "jdbc:oracle:thin:@localhost:1521/ORCLCDB.localdomain"; +string user = "balUser"; +string password = "balpass"; + +@test:Config { + groups: ["connection", "connection-init"] +} +function testWithURLParams() returns error? { + jdbc:Client dbClient = check new (url, user, password); + sql:Error? closeResult = dbClient.close(); + test:assertExactEquals(closeResult, (), "Initialising connection with params fails."); +} + +@test:Config { + groups: ["connection", "connection-init"] +} +function testWithConnectionPool() returns error? { + sql:ConnectionPool connectionPool = { + maxOpenConnections: 25, + maxConnectionLifeTime : 45, + minIdleConnections : 15 + }; + jdbc:Client dbClient = check new (url = url, user = user, password = password, connectionPool = connectionPool); + sql:Error? closeResult = dbClient.close(); + test:assertExactEquals(closeResult, (), "Initialising connection with option max connection pool fails."); + test:assertEquals(connectionPool.maxOpenConnections, 25, "Configured max connection config is wrong."); + test:assertEquals(connectionPool.maxConnectionLifeTime, 45, "Configured max connection life time second is wrong."); + test:assertEquals(connectionPool.minIdleConnections, 15, "Configured min idle connection is wrong."); +} + +@test:Config { + groups: ["connection", "connection-init"] +} +function testWithClosedClient1() returns error? { + jdbc:Client dbClient = check new (url = url, user = user, password = password); + sql:Error? closeResult = dbClient.close(); + test:assertExactEquals(closeResult, (), "Initialising connection with connection params fails."); + sql:ExecutionResult|sql:Error result = dbClient->execute(`CREATE TABLE test (id int)`); + if (result is sql:Error) { + string expectedErrorMessage = "SQL Client is already closed, hence further operations are not allowed"; + test:assertTrue(result.message().startsWith(expectedErrorMessage), + "Error message does not match, actual :\n'" + result.message() + "'\nExpected : \n" + expectedErrorMessage); + } else { + test:assertFail("Error expected"); + } +} From 4004b65406c0aa8a3a5698e68654b06752b940e1 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Fri, 3 Dec 2021 10:47:36 +0530 Subject: [PATCH 2/5] Add newline EOF --- .github/workflows/stale-check.yml | 2 +- .gitignore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale-check.yml b/.github/workflows/stale-check.yml index 9f487da..8763360 100644 --- a/.github/workflows/stale-check.yml +++ b/.github/workflows/stale-check.yml @@ -16,4 +16,4 @@ jobs: days-before-pr-stale: 15 days-before-pr-close: 3 days-before-issue-stale: -1 - days-before-issue-close: -1 \ No newline at end of file + days-before-issue-close: -1 diff --git a/.gitignore b/.gitignore index 4117d71..179819f 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,4 @@ hs_err_pid* build # -*.log \ No newline at end of file +*.log From a5fcab79e4339a9c424f154be0520fd4ad1a1962 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Fri, 3 Dec 2021 10:59:37 +0530 Subject: [PATCH 3/5] Amend workflows --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5dc8fb..dc67d84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,4 +20,4 @@ jobs: uses: ballerina-platform/ballerina-action/@slbeta5 with: args: - build -c --skip-tests + build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index abf6964..16fd545 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: uses: ballerina-platform/ballerina-action/@slbeta5 with: args: - build -c --skip-tests + build - name: Ballerina Push uses: ballerina-platform/ballerina-action/@slbeta5 with: From db4c73be0f5188ebf216bd0c0cf4ca98bd9dc2a1 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Fri, 3 Dec 2021 11:11:49 +0530 Subject: [PATCH 4/5] Change project version --- Ballerina.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ballerina.toml b/Ballerina.toml index 409cadd..193c628 100644 --- a/Ballerina.toml +++ b/Ballerina.toml @@ -1,7 +1,7 @@ [package] org="ballerinax" name="oracledb.driver" -version="1.2.0" +version="1.0.0" authors=["Ballerina"] keywords=["OracleDB"] repository="https://github.com/ballerina-platform/module-ballerinax-oracledb.driver" From 9ea4796fac13182415e0df964ad5963c867278a0 Mon Sep 17 00:00:00 2001 From: Kaneel Dias Date: Fri, 3 Dec 2021 11:18:17 +0530 Subject: [PATCH 5/5] Fix documentation issues --- Package.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.md b/Package.md index b66bb3f..067c2f2 100644 --- a/Package.md +++ b/Package.md @@ -12,7 +12,7 @@ This Package bundles the latest OracleDB drivers so that the OracleDB connector |Xmlparserv2 | **21.3.0.0** | -> The above are released under the [Oracle Free Use Terms and Conditions](https://www.oracle.com/downloads/licenses/oracle-free-license.html). +> The above OracleDB drivers are released under the [Oracle Free Use Terms and Conditions](https://www.oracle.com/downloads/licenses/oracle-free-license.html). ## Usage diff --git a/README.md b/README.md index dfa9253..764aad6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Ballerina OracleDB Driver Library =================== -The OracleDB Driver library is one of the external library packages of the Ballerina language. +The OracleDB Driver library is one of the external library packages of the +Ballerina language. This Package bundles the latest OracleDB drivers so that the OracleDB connector can be used in ballerina projects easily.