storage - GregHib/void GitHub Wiki

By default void saves players to /data/saves/*.json however when running in a production environment you might want to store in a database rather than json files, void support PostgreSQL out of the box, and other SQL databases with a little modification.

Postgresql

Storage using Postgresql is simple, replace the storage=files line in game.properties with storage=database and fill out the following details about your database:

storage=database
database_username=postgres # The database username
database_password=password # The database password
database_driver=org.postgresql.Driver # The database driver - see JDBC
database_jdbc_url=jdbc:postgresql://localhost:5432/game?reWriteBatchedInserts=true
database_pool=4 # Number of connections to use

JDBC

Java database connectivity (JDBC) is a specification for connecting to multiple types of SQL databases. By default Void only comes bundled with the Postgresql Driver but can support all major database providers.

Driver Support

Follow these steps to add support for your desired database, for this example we will add support for MySQL:

  1. In /engine/build.gradle.kts add the driver for the database of your choosing
implementation("com.mysql:mysql-connector-j:8.3.0")
  1. Build your server .jar on the command line by running
./gradlew assembleBundleDist

Which will create /game/build/distributions/void-dev.zip for you to use.

  1. In game.properties set the driver class name and jdbc url (as well as login credentials)
database_driver=com.mysql.jdbc.Driver
database_jdbc_url=jdbc:mysql://localhost:3306/game

Tip

This information can be found by googling "mysql jdbc driver maven" and "mysql jdbc driver class name"

Now when you run your game it will connect to the database specified in the JDBC url, load and store player data there.

⚠️ **GitHub.com Fallback** ⚠️