= Default database connector configuration
:description: The Bonita Studio includes a generic database connector that allows both JDBC and Datasource configurations

The Bonita Studio includes a generic database connector that allows both JDBC and Datasource configurations

There are two types of configuration for database connectors:

* A JDBC connector is a point-to-point connection configured with information to access the database directly.
* A datasource connector is a connection to a datasource that is an intermediate point between the user (the Bonita process) and the database. +
The advantage of using a datasource is that it can use a connection pool. The details of how the datasource retrieves information and the database it uses are hidden from the connector.

== How to configure a JDBC connector

These configuration steps are the same for all database connectors except the datasource connector.

. Select the Database connector, for example, JDBC 4 database query. Click *_Next_*.
. Enter the *Name*, *description*, *event* and**error message** (if any). Click *_Next_*.
. Select the *.jar file* of the database driver. Click *_Next_*.
. Enter the *Access information*. Click *_Next_*.
. Enter the *Input query*. This is a query to send to the database. You can put single or multiple queries separated by a separator.
You can also use the xref:graphical-query-builder.adoc[graphical query builder] to specify the query. Click *_Next_*.
. Choose how you want to specify the operations on connector outputs. Choose *Graphical mode* or *Scripting mode*. +
The Graphical mode does not require scripting. Click *_Next_*.
. Specify the output operations, using the xref:initialize-a-variable-from-a-database-without-scripting-or-java-code.adoc[Graphical mode] or using expressions.
. In the *Edit expression window*, set the *provided variable* to get data from the external database.
. Click *_Finish_*.

NOTE: in the return type, the type of the variable from the database must match the type of variable which is saved to the process variable.

== How to configure a datasource connector

Before you can configure the datasource connector, you need to configure the datasource itself, which is done in the application server. +
Follow the instructions in your application server documentation. http://tomcat.apache.org/tomcat-8.5-doc/jndi-datasource-examples-howto.html#PostgreSQL[See here for an example using Tomcat with PostgreSQL.] +
Configure the connections of the datasource to be created with auto commit set to true. +
Make sure that all elements using connections return them to the pool with auto commit still set to true.

A datasource connector can be used in a Database Connection Pool (DBCP). A DBCP is a group of connections. Multiple connections are "reserved" and used as needed.

To configure the datasource connector, you need the following information:

* The datasource name (for example `java:/comp/env/yourDataSource`).
* Optionally, depending on how the datasource is configured, the properties needed to access it. These are specified as name-value pairs.

To configure the datasource connector, follow these steps:

. Select the *Datasource database query* connector. Click *_Next_*.
. Enter the *Name*, *Description*, *Event* and *error message* (if any). Click *_Next_*.
. Specify the datasource name and, optionally, properties. Click *_Next_*.
. Enter the *Input query*. This is a query to send to the database. You can put single or multiple queries separated by a separator.
You can also use the xref:graphical-query-builder.adoc[graphical query builder] to specify the query. Click *_Next_*.
. Choose how you want to specify the operations on connector outputs. Choose *Graphical mode* or *Scripting mode*.
The Graphical mode does not require scripting. Click *_Next_*.
. Specify the output operations, using the xref:initialize-a-variable-from-a-database-without-scripting-or-java-code.adoc[Graphical mode] or using expressions.
. In the *Edit expression window*, set the *provided variable* to get data from the external database.
. Click *_Finish_*.
