Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change project to use Ballerina OracleDB driver #501

Merged
merged 10 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ Ballerina OracleDB Library
This library provides the functionality required to access and manipulate data stored in an Oracle database.

### Prerequisite
Add the OracleDB thin driver `ojdbc8.jar` along with `xdb.jar` and `xmlparserv2.jar` as native library dependencies in your Ballerina project's `Ballerina.toml` file.
It is recommended to use an oracle thin driver `ojdbc8.jar` version greater than 12.2.0.1.
It is required to import the OracleDB driver dependencies in order to connect to a Oracle database. The `ballerinax/oracledb.driver`
package bundles the latest OracleDB drivers so that the oracledb connector can be used in Ballerina projects easily.

```ballerina
import ballerinax/oracledb.driver as _;
```

If it is required to use a specific Oracledb driver JARs (`ojdbc8.jar` along with `xdb.jar` and `xmlparserv2.jar`), they can be added as a native library dependencies in your
Ballerina project's `Ballerina.toml` file. It is recommended to use an oracle thin driver `ojdbc8.jar` version greater than 12.2.0.1.

Follow one of the methods below to add the JAR in the file:

Expand Down
18 changes: 3 additions & 15 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "oracledb"
version = "1.6.0"
version = "1.6.1"
authors = ["Ballerina"]
keywords = ["database", "client", "network", "SQL", "RDBMS", "OracleDB", "Oracle"]
repository = "https://github.com/ballerina-platform/module-ballerinax-oracledb"
Expand All @@ -12,23 +12,11 @@ distribution = "2201.3.0"
[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "oracledb-native"
version = "1.6.0"
path = "../native/build/libs/oracledb-native-1.6.0.jar"
version = "1.6.1"
path = "../native/build/libs/oracledb-native-1.6.1-SNAPSHOT.jar"

[[platform.java11.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "sql-native"
version = "1.6.0"
path = "./lib/sql-native-1.6.0.jar"

[[platform.java11.dependency]]
path = "./lib/ojdbc8-12.2.0.1.jar"
scope = "testOnly"

[[platform.java11.dependency]]
path = "./lib/xdb-21.1.0.0.jar"
scope = "testOnly"

[[platform.java11.dependency]]
path = "./lib/xmlparserv2-12.2.0.1.jar"
scope = "testOnly"
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "oracledb-compiler-plugin"
class = "io.ballerina.stdlib.oracledb.compiler.OracleDBCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/oracledb-compiler-plugin-1.6.0.jar"
path = "../compiler-plugin/build/libs/oracledb-compiler-plugin-1.6.1-SNAPSHOT.jar"
14 changes: 12 additions & 2 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "oracledb"
version = "1.6.0"
version = "1.6.1"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "file"},
Expand All @@ -403,10 +403,20 @@ dependencies = [
{org = "ballerina", name = "sql"},
{org = "ballerina", name = "test"},
{org = "ballerina", name = "time"},
{org = "ballerinai", name = "transaction"}
{org = "ballerinai", name = "transaction"},
{org = "ballerinax", name = "oracledb.driver"}
]
modules = [
{org = "ballerinax", packageName = "oracledb", moduleName = "oracledb"}
]

[[package]]
org = "ballerinax"
name = "oracledb.driver"
version = "1.2.0"
scope = "testOnly"
modules = [
{org = "ballerinax", packageName = "oracledb.driver", moduleName = "oracledb.driver"}
]


11 changes: 9 additions & 2 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
This module provides the functionality required to access and manipulate data stored in an Oracle database.

### Prerequisite
Add the OracleDB thin driver `ojdbc8.jar` along with `xdb.jar` and `xmlparserv2.jar` as native library dependencies in your Ballerina project's `Ballerina.toml` file.
It is recommended to use an oracle thin driver `ojdbc8.jar` version greater than 12.2.0.1.
It is required to import the OracleDB driver dependencies in order to connect to a Oracle database. The `ballerinax/oracledb.driver`
package bundles the latest OracleDB drivers so that the oracledb connector can be used in Ballerina projects easily.

```ballerina
import ballerinax/oracledb.driver as _;
```

If it is required to use a specific Oracledb driver JARs (`ojdbc8.jar` along with `xdb.jar` and `xmlparserv2.jar`), they can be added as a native library dependencies in your
Ballerina project's `Ballerina.toml` file. It is recommended to use an oracle thin driver `ojdbc8.jar` version greater than 12.2.0.1.

Follow one of the methods below to add the JAR in the file:

Expand Down
11 changes: 9 additions & 2 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
This package provides the functionality required to access and manipulate data stored in an Oracle database.

### Prerequisite
Add the OracleDB thin driver `ojdbc8.jar` along with `xdb.jar` and `xmlparserv2.jar` as native library dependencies in your Ballerina project's `Ballerina.toml` file.
It is recommended to use an oracle thin driver `ojdbc8.jar` version greater than 12.2.0.1.
It is required to import the OracleDB driver dependencies in order to connect to a Oracle database. The `ballerinax/oracledb.driver`
package bundles the latest OracleDB drivers so that the oracledb connector can be used in Ballerina projects easily.

```ballerina
import ballerinax/oracledb.driver as _;
```

If it is required to use a specific Oracledb driver JARs (`ojdbc8.jar` along with `xdb.jar` and `xmlparserv2.jar`), they can be added as a native library dependencies in your
Ballerina project's `Ballerina.toml` file. It is recommended to use an oracle thin driver `ojdbc8.jar` version greater than 12.2.0.1.

Follow one of the methods below to add the JAR in the file:

Expand Down
3 changes: 0 additions & 3 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ task updateTomlFiles {
newConfig = newConfig.replace('@sql.version@', stdlibDependentSqlVersion)
newConfig = newConfig.replace('@stdlib.sql.native.version@', project.stdlibSqlVersion.toString())
newConfig = newConfig.replace('@stdlib.sql.version@', stdlibDependentSqlVersion)
newConfig = newConfig.replace('@oracledb.driver.version@', project.oracleDBDriverVersion)
newConfig = newConfig.replace('@oracle.xdb.version@', project.oracleXDBVersion)
newConfig = newConfig.replace('@oracle.xmlparserv2.version@', project.oracleXMLParserVersion)
ballerinaTomlFile.text = newConfig

def newCompilerPluginToml = compilerPluginTomlFilePlaceHolder.text.replace("@project.version@", project.version)
Expand Down
16 changes: 8 additions & 8 deletions ballerina/tests/01-connection-init-test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ isolated function testWithOptionsWithErroneousSSL() returns error? {

test:assertTrue(oracledbClient is error);
if oracledbClient is sql:ApplicationError {
test:assertTrue(oracledbClient.message().startsWith("Error in SQL connector configuration: Failed to initialize pool: " +
"IO Error: closing inbound before receiving peer's close_notify"));
test:assertTrue(oracledbClient.message().startsWith("Error in SQL connector configuration: Failed to initialize pool: " +
"IO Error: Connection closed"));
} else {
test:assertFail("Error ApplicatonError expected");
test:assertFail("Error Application Error expected");
}

Client|error oracledbClient2 = new (
Expand All @@ -178,10 +178,10 @@ isolated function testWithOptionsWithErroneousSSL() returns error? {

test:assertTrue(oracledbClient2 is error);
if oracledbClient2 is sql:ApplicationError {
test:assertTrue(oracledbClient2.message().startsWith("Error in SQL connector configuration: Failed to initialize pool: " +
"IO Error: closing inbound before receiving peer's close_notify"));
test:assertTrue(oracledbClient2.message().startsWith("Error in SQL connector configuration: Failed to initialize pool: " +
"IO Error: Connection closed"));
} else {
test:assertFail("Error ApplicatonError expected");
test:assertFail("Error Application Error expected");
}

Client|error oracledbClient3 = new (
Expand Down Expand Up @@ -231,8 +231,8 @@ function testWithOptionsWithErroneousSSLCorrectPort() returns error? {
);
test:assertTrue(oracledbClient is error);
if oracledbClient is sql:ApplicationError {
test:assertTrue(oracledbClient.message().startsWith("Error in SQL connector configuration: Failed to initialize pool: " +
"IO Error: PKIX path building failed: unable to find valid certification path to requested target"));
test:assertTrue(oracledbClient.message().startsWith("Error in SQL connector configuration: Failed to initialize pool: " +
"IO Error: IO Error PKIX path building failed: unable to find valid certification path to requested target"));
} else {
test:assertFail("Application Error expected");
}
Expand Down
12 changes: 4 additions & 8 deletions ballerina/tests/11-custom-object-type-test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ isolated function insertObjectTypeWithNullArray() returns sql:Error? {
isolated function insertObjectTypeWithEmptyArray() returns sql:Error? {
ObjectTypeValue objectType = new ({typename: "object_type", attributes: []});
sql:ParameterizedQuery insertQuery = `INSERT INTO TestObjectTypeTable(COL_OBJECT) VALUES(${objectType})`;
sql:ExecutionResult|sql:Error result = executeQuery(insertQuery);
if result is sql:DatabaseError {
sql:DatabaseErrorDetail errorDetails = result.detail();
test:assertEquals(errorDetails.errorCode, 17049);
test:assertEquals(errorDetails.sqlState, "99999");
} else {
test:assertFail("Database Error expected.");
}
sql:ExecutionResult result = check executeQuery(insertQuery);
test:assertExactEquals(result.affectedRowCount, 1, "Affected row count is different.");
int|string? insertId = result.lastInsertId;
test:assertTrue(insertId is string, "Last Insert id should be string");
}

@test:Config {
Expand Down
1 change: 1 addition & 0 deletions ballerina/tests/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import ballerina/io;
import ballerina/sql;
import ballerinax/oracledb.driver as _;

isolated function getByteColumnChannel() returns io:ReadableByteChannel|error {
io:ReadableByteChannel byteChannel = check io:openReadableFile("./tests/resources/files/byteValue.txt");
Expand Down
12 changes: 0 additions & 12 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,3 @@ groupId = "io.ballerina.stdlib"
artifactId = "sql-native"
version = "@sql.version@"
path = "./lib/[email protected]@.jar"

[[platform.java11.dependency]]
path = "./lib/[email protected]@.jar"
scope = "testOnly"

[[platform.java11.dependency]]
path = "./lib/[email protected]@.jar"
scope = "testOnly"

[[platform.java11.dependency]]
path = "./lib/[email protected]@.jar"
scope = "testOnly"
11 changes: 1 addition & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,7 @@ subprojects {
ballerinaStdLibs "io.ballerina.stdlib:url-ballerina:${stdlibUrlVersion}"
ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}"
ballerinaStdLibs "io.ballerina:observe-ballerina:${observeInternalVersion}"

externalJars (group: 'com.oracle.database.jdbc', name: 'ojdbc8', version: "${oracleDBDriverVersion}") {
transitive = false
}
externalJars (group: 'com.oracle.database.xml', name: 'xdb', version: "${oracleXDBVersion}") {
transitive = false
}
externalJars (group: 'com.oracle.database.xml', name: 'xmlparserv2', version: "${oracleXMLParserVersion}") {
transitive = false
}
ballerinaStdLibs "io.ballerina.stdlib:oracledb.driver-ballerina:${stdlibOracledbDriverVersion}"
}
}

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed
- [Updated API Docs to use `oracledb.driver`](https://github.com/ballerina-platform/ballerina-standard-library/issues/3710)

## [1.6.0] - 2022-11-29

Expand Down
15 changes: 0 additions & 15 deletions examples/online-shop/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,3 @@
org = "online"
name = "shop"
version = "0.1.0"

[[dependency]]
org = "ballerinax"
name = "oracledb"
version = "1.0.0"
repository = "local"

[[platform.java11.dependency]]
path = "./../../ballerina/lib/ojdbc8-12.2.0.1.jar"

[[platform.java11.dependency]]
path = "./../../ballerina/lib/xdb-21.1.0.0.jar"

[[platform.java11.dependency]]
path = "./../../ballerina/lib/xmlparserv2-12.2.0.1.jar"
1 change: 1 addition & 0 deletions examples/online-shop/service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ballerina/http;
import ballerinax/oracledb;
import ballerina/sql;
import ballerinax/oracledb.driver as _;

configurable string USER = ?;
configurable string PASSWORD = ?;
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ version=1.6.1-SNAPSHOT

puppycrawlCheckstyleVersion=8.18
oracleDBDriverVersion=12.2.0.1
oracleXDBVersion=21.1.0.0
oracleXMLParserVersion=12.2.0.1
checkstyleToolVersion=7.8.2
githubSpotbugsVersion=4.0.5
githubJohnrengelmanShadowVersion=5.2.0
Expand Down Expand Up @@ -58,3 +56,6 @@ stdlibHttpVersion=2.5.0

# Level 06
stdlibTransactionVersion=1.3.0

# Ballerina extended library
stdlibOracledbDriverVersion=1.2.0

This file was deleted.

Loading