Skip to content

Commit 01ff6f7

Browse files
committed
Define jdbc advanced configurations
1 parent 246ae4e commit 01ff6f7

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

ballerina/tests/h2_rainier_generated_client.bal

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
// KIND, either express or implied. See the License for the
1414
// specific language governing permissions and limitations
1515
// under the License.
16-
1716
import ballerina/jballerina.java;
18-
import ballerinax/java.jdbc as jdbc;
19-
import ballerinax/h2.driver as _;
20-
import ballerina/sql;
2117
import ballerina/persist;
18+
import ballerina/sql;
19+
import ballerinax/h2.driver as _;
20+
import ballerinax/java.jdbc as jdbc;
2221

2322
const EMPLOYEE = "employees";
2423
const WORKSPACE = "workspaces";
@@ -135,7 +134,7 @@ public isolated client class H2RainierClient {
135134
};
136135

137136
public isolated function init() returns persist:Error? {
138-
jdbc:Client|error dbClient = new (url = h2.url, user = h2.user, password = h2.password);
137+
jdbc:Client|error dbClient = new (url = h2.url, user = h2.user, password = h2.password, options = {...h2.connectionOptions});
139138
if dbClient is error {
140139
return <persist:Error>error(dbClient.message());
141140
}

ballerina/tests/h2_test_entities_generated_client.bal

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ballerina/jballerina.java;
12
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
23
//
34
// WSO2 LLC. licenses this file to you under the Apache License,
@@ -13,12 +14,10 @@
1314
// KIND, either express or implied. See the License for the
1415
// specific language governing permissions and limitations
1516
// under the License.
16-
1717
import ballerina/persist;
18-
import ballerina/jballerina.java;
19-
import ballerinax/java.jdbc as jdbc;
20-
import ballerinax/h2.driver as _;
2118
import ballerina/sql;
19+
import ballerinax/h2.driver as _;
20+
import ballerinax/java.jdbc as jdbc;
2221

2322
const ALL_TYPES = "alltypes";
2423
const STRING_ID_RECORD = "stringidrecords";
@@ -154,7 +153,7 @@ public isolated client class H2TestEntitiesClient {
154153
};
155154

156155
public isolated function init() returns persist:Error? {
157-
jdbc:Client|error dbClient = new (url = h2.url, user = h2.user, password = h2.password);
156+
jdbc:Client|error dbClient = new (url = h2.url, user = h2.user, password = h2.password, options = {...h2.connectionOptions});
158157
if dbClient is error {
159158
return <persist:Error>error(dbClient.message());
160159
}

ballerina/tests/init-tests.bal

+15
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,23 @@ configurable record {|
2828
string url;
2929
string user;
3030
string password;
31+
Options connectionOptions = {};
3132
|} & readonly h2 = ?;
3233

34+
35+
public type Options record {|
36+
string datasourceName?;
37+
map<anydata> properties?;
38+
Operations requestGeneratedKeys = ALL;
39+
|};
40+
41+
public enum Operations {
42+
NONE,
43+
EXECUTE,
44+
BATCH_EXECUTE,
45+
ALL
46+
}
47+
3348
configurable record {|
3449
int port;
3550
string host;

0 commit comments

Comments
 (0)