Database Setup — Connecting Java to a Systron MySQL Database Print

  • Java, MySQL, Database
  • 42

Connecting Your Java Application to a MySQL Database

Every Systron Java hosting plan comes with a MySQL database allocation. Follow these steps to configure your database settings and connect it using standard Java tools.

Step 1: Create the Database Credentials

  • Log in to your control panel and click on Databases in the menu sidebar.
  • Click Add Database.
  • Type in a database name, create a new database user, and choose a secure password. Note down these three values.
  • Keep the database host target as localhost or 127.0.0.1 since the database resides on the same physical system.

Step 2: Add Your Database Driver

Your application requires a database driver library to talk to MySQL. Ensure the MySQL Connector/J dependency is included in your build configurations:

  • For Maven: Add the mysql-connector-j artifact group dependency inside your pom.xml file.
  • For Gradle: Include the implementation runtime parameter for the MySQL connector within your build.gradle file.
  • For Manual Bundles: Ensure the mysql-connector-java-xxx.jar binary file is safely dropped inside your application's WEB-INF/lib/ directory before you package the final layout.

Step 3: Standard JDBC Connection Properties

You can use standard JDBC parameters to establish your database manager pool. We strongly recommend loading these configurations through external configuration properties files or system variables rather than hardcoding them into compiling classes:

# Example database properties configuration
db.url=jdbc:mysql://localhost:3306/YOUR_DATABASE_NAME?useSSL=false&serverTimezone=UTC
db.username=YOUR_DATABASE_USER
db.password=YOUR_DATABASE_PASSWORD
db.driver=com.mysql.cj.jdbc.Driver

After saving your configuration files and redeploying your archive, restart the application backend from your control panel dashboard to establish the data pipeline.


Was this answer helpful?

« Back