Configuring JDBC on Martini Server Runtime
Martini Server Runtime enables seamless connection to various Java Database Connectivity (JDBC) relational (SQL) databases and facilitates SQL operations execution against them. Ensure the appropriate drivers are installed for smooth database connectivity.
Database Properties
The table below outlines the configurable properties for a database connection:
Field Name | Parameters | Required | Default Value | Description |
---|---|---|---|---|
Name | name |
true | null | Name of the database connection. |
Auto Start | autoStart |
false | true |
Whether the database connection should start when Martini starts up. |
Type | type |
true | null | Selects the database type. (jdbc , cassandra , redis , mongodb , aws-sqs , gcp-bigtable ) |
Use XA | xa |
false | false |
Whether or not to enable XA transactions. |
Driver Class | driverClassName |
true | null | The JDBC driver for the database you are connecting to. |
URL | url |
true | null | The URL of the JDBC database you are connecting to. |
Username | username |
true | null | Username to use when connecting to the database. |
Password | password |
false | null | Password to use when connecting to the database. Passwords will be encrypted after running. |
Acquire Increment | acquireIncrement |
false | 1 |
Controls how many connections are filled into the pool when the pool is empty but the maxPoolSize has not been reached. |
Acquisition Interval | acquisitionInterval |
false | 1 |
Controls how long (in seconds) the pool waits between attempts to create new connections. |
Acquisition Timeout | acquisitionTimeout |
false | 30 |
Controls how long (in seconds) to wait for a pool connection request to succeed before being aborted (and throwing an exception). |
Login Timeout | loginTimeout |
false | 0 |
Controls how long (in seconds) to wait for a successful authentication against the database server. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it assumes that there is no timeout. |
Allow Local Transactions | allowLocalTransactions |
false | true |
Whether or not you want to be able to run SQL statements outside of XA transactions scope. |
Auto Commit | autoCommit |
false | true |
Determines how transactions are handled in your database. |
Apply XA Transaction Timeout | applyTransactionTimeout |
false | false |
Whether or not the transaction timeout will be passed to the resource via XAResource#setTransactionTimeout(int) . |
Enlist to XA Automatically | automaticEnlistingEnabled |
false | true |
Controls whether connections from the PoolingDataSource are automatically enlisted or delisted in XA transactions. |
Defer Connection Release | deferConnectionRelease |
false | false |
Set this parameter to false if the vendor's XADataSource implementation supports the interleaving of transactions. |
Enable JDBC4 Connection Test | enableJdbc4ConnectionTest |
false | false |
If your JDBC driver supports JDBC4, this method of testing the connection is likely much more efficient than using the testQuery parameter. |
Ignore Recovery Failures | ignoreRecoveryFailures |
false | false |
Determines whether recovery errors should be ignored or not. This is useful in development environments. |
Maximum Idle Time | maxIdleTime |
false | 60 |
When the pool is above the minPoolSize, this parameter controls how long (in seconds) an idle connection will stay in the pool before being retired. |
Isolation Level | isolationLevel |
false | READ_COMMITTED |
Sets the default isolation level. All of the four standard values (READ_COMMITTED , READ_UNCOMMITTED , REPEATABLE_READ and SERIALIZABLE ) are supported. |
Minimum Pool Size | minPoolSize |
false | 0 |
The minimum number of active connections the pool will try to keep. |
Maximum Pool Size | maxPoolSize |
false | 5 |
The maximum number of active connections allowed in the pool. |
Prepared Statements Cache Size | preparedStatementCacheSize |
false | 0 |
Controls how many prepared statements are cached (per connection) by Bitronix. |
Share Transaction Connections | shareTransactionConnections |
false | false |
Determines whether or not connections share the same thread context. |
Test Query | testQuery |
false | null | In contrast with enableJdbc4ConnectionTest , this query is sent to the database to determine whether or not a connection is still usable. |
Two-Phase Commit Order Position | twoPcOrderingPosition |
false | 0 |
Controls the position of this resource during the 2PC protocol execution; used to guarantee the order of commits. |
Unique Name | uniqueName |
false | "Name" |
Required for crash recovery; uses "Name" if empty. |
Use Transaction Manager Join | useTmJoin |
false | true |
Set this parameter to false if the vendor's XADataSource implementation does not implement XAResource#isSameRM(...) properly. |
Supported databases
Here is the list of all databases that are supported by Martini Runtime with embedded drivers:
Database Name |
---|
HSQLDB |
MySQL |
PostgreSQL |
SQL Server |
Oracle |
Snowflake |
Redshift |
Presto |
Note: If your database isn't listed above but is JDBC compliant, you'll need to manually install the JDBC driver. Follow the instructions in the Installing a New Driver guide. However, please be aware that Martini Runtime may not formally support all third-party drivers.
Installing Additional Database Drivers
Martini Server Runtime utilizes JDBC drivers for database connectivity. Besides the built-in drivers, you can install additional drivers for a JDBC compliant database.
Installing a New Driver
To add a new database driver:
- Obtain the respective driver JAR file.
- Place the JAR file in the
<martini-home>/lib/ext/
directory. - Restart Martini Server Runtime.
After this process, the newly installed driver will be visible for selection when adding a new database connection.
Testing Database Connections
While optional, it's advisable to test the database connectivity before saving any changes to ensure successful connection establishment.
Configuration
Follow these steps to modify the properties of a database connection:
- Stop the database connection you want to configure.
- Right click on the database connection and click Configure from the context menu.
- Edit the properties of the database connection in the displayed editor.
- Save your changes.