Skip to content

Configuring Databases on Martini Server Runtime

Database configuration is a critical component of managing and operating the Martini platform. All database connection settings, including driver details, connection URLs, usernames, and passwords, are managed through a dbxml file corresponding to each database connection. This centralized configuration approach simplifies the setup and maintenance of database connections used across your Martini instances. The dbxml files are located here:

1
2
3
4
5
6
├── martini-home
│   ├── conf
│   │   └── db-pool
│   │       └── DbConnectionName.dbxml 
│   |...
|...

Secure Storage of Credentials

Security is paramount when dealing with database connections, particularly the storage and handling of passwords. In Martini, any password specified in the dbxml file is automatically encrypted when the Martini Runtime Server starts. This encryption process uses robust cryptographic techniques to ensure that passwords are not exposed in plain text, thereby protecting your data from unauthorized access.

For a deeper understanding of the encryption methods used and how Martini ensures the security of your database credentials and other sensitive data, please refer to our comprehensive Security Documentation. This section offers insights into our security practices, encryption standards, and tips for maintaining a secure Martini environment.

Environmental Variables

Martini supports flexible database configurations through the use of environmental variables. This feature allows system administrators and developers to pass configuration settings at runtime, without modifying the dbxml file directly. Utilizing environmental variables is particularly beneficial in environments where configurations might vary between deployments, such as different stages in a development pipeline or across multiple deployment platforms.

Environmental variables can be used to dynamically set values for database connection strings, usernames, passwords, and other configuration details. This method supports best practices in configuration management by keeping environment-specific settings separate from application code and minimizing changes to version-controlled files.

For example you have a dbxml file with properties:

1
2
3
4
5
<database>
  <maxIdleTime>60</maxIdleTime>
  <minPoolSize>0</minPoolSize>
  <maxPoolSize>5</maxPoolSize>
</database>

Instead of inputting the values directly, you can edit your dbxml file like this:

1
2
3
4
5
<database>
  <maxIdleTime>${maxIdleTime}</maxIdleTime>
  <minPoolSize>${minPoolSize}</minPoolSize>
  <maxPoolSize>${maxPoolSize}</maxPoolSize>
</database>

By using variables such as ${maxIdleTime}, ${minPoolSize}, and ${maxPoolSize} in your dbxml file, you enable dynamic configuration that can be easily adjusted without modifying the actual file. This approach enhances the flexibility and scalability of your application, allowing environmental variables to dictate these values. It simplifies maintenance and deployment across different environments, ensuring that your database settings are both adaptable and consistently applied.

For more instructions on how to define and use environmental variables within your Martini setup, including examples of variable names and usage practices, please visit our Environment Variables Documentation. This guide provides all the necessary information to effectively manage your database settings in a flexible and secure manner.

By adhering to these guidelines and leveraging the built-in features of Martini, you can ensure that your database connections are not only secure but also highly configurable and suited to your specific operational needs.