---
title: Configuring Datasource and Drives of Bank
slug: support-en/configuring-datasource-and-drives-of-bank
description: Learn how to create a datasource in the system with this comprehensive document. Discover step-by-step instructions for setting up a PostgreSQL datasource, including specific commands and configurations. Dive into the configuration settings for four diffe
docTags: 
createdAt: 2022-01-18T19:18:52.000Z
---

Before creating a datasource, it's necessary to add a database module to the system. Each base
has its own connection driver, but all settings are based on the same principle: download the
driver from the manufacturer, copy it to wildfly and configure on the system. The settings will
be made via jboss-cli, but they can all be made via XML in the standalone-full.xml file if you
wish for it.

In the example below we'll use the PostgreSQL driver. Each database has its own configuration
method, we recommend looking in the database manufacturer's documentation of your choice if it
differs from our documentation.

The PostgreSQL JDBC driver download can be found at [https://jdbc.postgresql.org](https://jdbc.postgresql.org) at the downloads
link. The driver version used by CITSmart is 4.1 build 9.3 Build 1104.

```Text
[root@server /tmp]# wget https://jdbc.postgresql.org/download/postgresql-9.3-1104.jdbc41.jar
```

Access jboss-cli again to add the driver with the command below
(considering you have downloaded it to folder `/tmp`):

```Text
[standalone@localhost:9990 /] module add --name=org.postgres --resources=/tmp/postgresql-9.3-1104.jdbc41.jar --dependencies=javax.api,javax.transaction.api
```

With this command, the driver will be automatically added to the folder
`/opt/wildfly-12.0.0.Final/modules/org/postgres/main/`

Continue to the CLI and run the command below to add a datasource:

```Text
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource
```

## Creating the CITSmart database

Regardless of the database architecture (whether installed on the same server or separately) the
steps below are for creating a database and user for CITSmart. In the procedure we assume that
you have access to the DBMS. Access PostgreSQL with the command below:

```Text
[root@server /tmp]#  su - postgres
bash-4.2$
bash-4.2$ psql
psql (9.6.15)
Type "help" for help.

postgres=#
```

Create a password and user to get access to the CITSmart base (replace YOUR\_PASSWORD with a
preferred password):

```Text
postgres=# create user citsmartdbuser with password 'YOUR_PASSWORD';
CREATE ROLE
postgres=#
```

Create a database to the CITSmart:

```Text
postgres=# create database citsmart_db with owner citsmartdbuser encoding 'UTF8' tablespace pg_default;
CREATE DATABASE
postgres=#
```

Give permission to the CITSmart user:

```Text
postgres=# alter role citsmartdbuser superuser;
ALTER ROLE
postgres=#
```

Leave the PSQL and shell of the postgres user:

```Text
postgres=# \q
bash-4.2$ exit
exit
[root@server /tmp]#
```

If the base is running on the same server, it's necessary to release the connection to the
CITSmart user. Edit the file
`/var/lib/pgsql/9.6/data/pg_hba.conf` and include the following line:

```Text
# Database administrative login by Unix domain socket
local   all             postgres                                ident
```

!!! Warning "ATTENTION"

```Text
Do not change the `local all postgres peer` line that comes by default, include the line above 
just below this one.
```

If the database is running on another server, it's necessary to release the connection from the
Wildfly. To do this, add the following line in the same pg\_hba.conf file, replacing it with the
Wildfly server IP address:

```Text
host citsmart_db citsmartdbuser WILDFLY_IP_ADDRESS/32 md5
```

## Configuring the datasource to CITSmart

There are eight datasource entries for citsmart\_db, four for CITSmart and four for CITSmart
Neuro. The user and password is citsmartdbuser and YOUR\_PASSWORD created in the previous step.
If you have created a different user, password, and database, change it in the commands below.

Conect in the jboss-cli and run the following commands:

### Datasource citsmart

```Text
/subsystem=datasources/data-source="/jdbc/citsmart":add(jndi-name="java:/jdbc/citsmart",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/jdbc/citsmart":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/jdbc/citsmart":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/jdbc/citsmart":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/jdbc/citsmart":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/jdbc/citsmart":write-attribute(name=blocking-timeout-wait-millis,value=60000)
/subsystem=datasources/data-source="/jdbc/citsmart":write-attribute(name=idle-timeout-minutes,value=5)
```

### Datasource citsmartFlow

```Text
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":add(jndi-name="java:/jdbc/citsmartFluxo",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":write-attribute(name=blocking-timeout-wait-millis,value=60000)
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":write-attribute(name=idle-timeout-minutes,value=5)
```

### Datasourece citsmart\_reports

```Text
/subsystem=datasources/data-source="/jdbc/citsmart_reports":add(jndi-name="java:/jdbc/citsmart_reports",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/jdbc/citsmart_reports":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/jdbc/citsmart_reports":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/jdbc/citsmart_reports":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/jdbc/citsmart_reports":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/jdbc/citsmart_reports":write-attribute(name=blocking-timeout-wait-millis,value=60000)
/subsystem=datasources/data-source="/jdbc/citsmart_reports":write-attribute(name=idle-timeout-minutes,value=5)
```

### Datasource citsmartBpmEventos

```Text
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":add(jndi-name="java:/jdbc/citsmartBpmEventos",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":write-attribute(name=blocking-timeout-wait-millis,value=60000)
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":write-attribute(name=idle-timeout-minutes,value=5
```

### Datasource citsmart-neuro

```Text
/subsystem=datasources/data-source="/env/jdbc/citsmart-neuro":add(jndi-name="java:/env/jdbc/citsmart-neuro",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=blocking-timeout-wait-millis,value=60000)#
```

### Datasource citsmart-neuro-app1

```Text
/subsystem=datasources/data-source="/env/jdbc/citsmart-neuro-app1":add(jndi-name="java:/env/jdbc/citsmart-neuro-app1",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=blocking-timeout-wait-millis,value=60000)
```

### Datasource citsmart-neuro-app2

```Text
/subsystem=datasources/data-source="/env/jdbc/citsmart-neuro-app2":add(jndi-name="java:/env/jdbc/citsmart-neuro-app2",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=blocking-timeout-wait-millis,value=60000)
```

### Datasource citsmart-neuro-app3

```Text
/subsystem=datasources/data-source="/env/jdbc/citsmart-neuro-app3":add(jndi-name="java:/env/jdbc/citsmart-neuro-app3",driver-name="postgres",connection-url="jdbc:postgresql://pgdata.citsmart.com:5432/citsmart_db",user-name="citsmartdbuser",password="exemplo123",driver-class="org.postgresql.Driver", enabled=true, use-java-context=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=min-pool-size,value=10)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=max-pool-size,value=300)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=pool-prefill,value=true)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=flush-strategy,value=FailingConnectionOnly)
/subsystem=datasources/data-source="/env\/jdbc\/citsmart-neuro":write-attribute(name=blocking-timeout-wait-millis,value=60000)
```

Before leaving the jboss-cli, run the reload command to apply the changes and test the database
connection:

```Text
[standalone@localhost:9990 /]: reload
```

And make a connection test with all bases with the commands below. Remember that
the result has to be `"outcome" => "success"`:

```Text
/subsystem=datasources/data-source="/jdbc/citsmart":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmartFluxo":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmart_reports":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmartBpmEventos":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmart-neuro":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmart-neuro-app1":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmart-neuro-app2":test-connection-in-pool
/subsystem=datasources/data-source="/jdbc/citsmart-neuro-app3":test-connection-in-pool
```

## Next step

[Configuring the
Wildfly](/en-us/citsmart-platform-8/get-started/installation-and-upgrade/perform-installation/conf-wildfly.html)
