Skip to content

Commit

Permalink
Merge pull request #800 from kaneeldias/main2
Browse files Browse the repository at this point in the history
  • Loading branch information
kaneeldias authored Sep 8, 2023
2 parents 5a4da39 + 218933b commit 6306ca2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,22 @@ The `atomic-batch-operation` project demonstrates how to use the PostgreSQL clie

* Install the PostgreSQL server and create a database

* Add required configurations in the `config.toml` file

* Follow one of the following ways to add PostgreSQL database driver JAR in the `Ballerina.toml` file:
* Download the JAR and update the path
```
[[platform.java17.dependency]]
path = "PATH"
```

* Replace the above path with a maven dependency param
```
[platform.java17.dependency]]
groupId = "org.postgresql"
artifactId = "postgresql"
version = "42.2.20"
```
* Add required configurations in the `Config.toml` file

# Run the example

To run the example, move into the `atomic-batch-operation` project and execute the below command.

```
$bal run
```shell
bal run
```
It will build the `atomic-batch-operation` Ballerina project and then run it.

# Output of the example

This gives the following output when running this project.

```ballerina
```shell
[ballerina/http] started HTTP/WS listener 192.168.1.10:55471
Error while executing batch command starting with: 'INSERT INTO Students
(firstName, lastName, registrationID, creditLimit, country)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,22 @@ The `batch-operation` project demonstrates how to use the PostgreSQL client to e

* Install the PostgreSQL server and create a database

* Add required configurations in the `config.toml` file

* Follow one of the following ways to add PostgreSQL database driver JAR in the `Ballerina.toml` file:
* Download the JAR and update the path
```
[[platform.java17.dependency]]
path = "PATH"
```

* Replace the above path with a maven dependency param
```
[platform.java17.dependency]]
groupId = "org.postgresql"
artifactId = "postgresql"
version = "42.2.20"
```
* Add required configurations in the `Config.toml` file

# Run the example

To run the example, move into the `batch-operation` project and execute the below command.

```
$bal run
```shell
bal run
```
It will build the `batch-operation` Ballerina project and then run it.

# Output of the example

This gives the following output when running this project.

```ballerina
```shell
Insert success, generated IDs are: [1,2,3]

Data in Customers table:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,22 @@ The `call-stored-operation` project demonstrates how to use the PostgreSQL clien

* Install the PostgreSQL server and create a database

* Add required configurations in the `config.toml` file

* Follow one of the following ways to add PostgreSQL database driver JAR in the `Ballerina.toml` file:
* Download the JAR and update the path
```
[[platform.java17.dependency]]
path = "PATH"
```

* Replace the above path with a maven dependency param
```
[platform.java17.dependency]]
groupId = "org.postgresql"
artifactId = "postgresql"
version = "42.2.20"
```
* Add required configurations in the `Config.toml` file

# Run the example

To run the example, move into the `call-stored-operation` project and execute the below command.

```
$bal run
```shell
bal run
```
It will build the `call-stored-operation` Ballerina project and then run it.

# Output of the example

This gives the following output when running this project.

```ballerina
```shell
Call stored procedure `InsertStudent`.
Inserted data: {"id":1,"age":24,"name":"George"}
Call stored procedure `GetCount`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,22 @@ This example demonstrates how to use the PostgreSQL client with complex data typ

* Install the PostgreSQL server and create a database

* Add required configurations in the `config.toml` file

* Follow one of the following ways to add PostgreSQL database driver JAR in the `Ballerina.toml` file:
* Download the JAR and update the path
```
[[platform.java17.dependency]]
path = "PATH"
```

* Replace the above path with a maven dependency param
```
[platform.java17.dependency]]
groupId = "org.postgresql"
artifactId = "postgresql"
version = "42.2.20"
```
* Add required configurations in the `Config.toml` file

# Run the example

To run the example, move into the `complex-queries-operation` project and execute the below command.
```
$bal run

```shell
bal run
```
It will build the `complex-queries-operation` Ballerina project and then run it.

# Output of the example

This gives the following output when running this project.

```ballerina
```shell
Json types Result :
{"row_id":1,"json_type":{"key1":"value","key2":2},"jsonb_type":{"key1":"value","key2":2},"jsonpath_type":"$."floor"[*]."apt"[*]?(@."area" > 40 && @."area" < 90)?(@."rooms" > 1)"}
Range type Result :
Expand Down
24 changes: 5 additions & 19 deletions examples/execute-operation/Executing Queries with PostgreSQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,22 @@ This example demonstrates how to use the PostgreSQL client with the DDL and DML

* Install the PostgreSQL server and create a database

* Add required configurations in the `config.toml` file

* Follow one of the following ways to add PostgreSQL database driver JAR in the `Ballerina.toml` file:
* Download the JAR and update the path
```
[[platform.java17.dependency]]
path = "PATH"
```

* Replace the above path with a maven dependency param
```
[platform.java17.dependency]]
groupId = "org.postgresql"
artifactId = "postgresql"
version = "42.2.20"
```
* Add required configurations in the `Config.toml` file

# Run the example

To run the example, move into the `execute-batch-operation` project and execute the below command.

```
$bal run
```shell
bal run
```
It will build the `execute-operation` Ballerina project and then run it.

# Output of the example

This gives the following output when running this project.

```ballerina
```shell
Rows affected: 1
Generated Customer ID: 2
Updated Row count: 1
Expand Down
24 changes: 5 additions & 19 deletions examples/query-operation/Performing Queries with PostgreSQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,22 @@ This example demonstrates how to use the PostgreSQL client select query operatio

* Install the PostgreSQL server and create a database

* Add required configurations in the `config.toml` file

* Follow one of the following ways to add PostgreSQL database driver JAR in the `Ballerina.toml` file:
* Download the JAR and update the path
```
[[platform.java17.dependency]]
path = "PATH"
```

* Replace the above path with a maven dependency param
```
[platform.java17.dependency]]
groupId = "org.postgresql"
artifactId = "postgresql"
version = "42.2.20"
```
* Add required configurations in the `Config.toml` file

# Run the example

To run the example, move into the `query-operation` project and execute the below command.

```
$bal run
```shell
bal run
```
It will build the `query-operation` Ballerina project and then run it.

# Output of the example

This gives the following output when running this project.

```ballerina
```shell
Full Customer details: {"customerid":1,"firstname":"Peter","lastname":"Stuart","registrationid":1,"creditlimit":5000.75,"country":"USA"}
Full Customer details: {"customerid":2,"firstname":"Dan","lastname":"Brown","registrationid":2,"creditlimit":10000.0,"country":"UK"}
Total rows in customer table : 2
Expand Down

0 comments on commit 6306ca2

Please sign in to comment.