Skip to content

Changing Database

Eliza Margaretha Illig edited this page May 23, 2024 · 10 revisions

** WARNING: The task in this page is not maintained continuously and may contain obsolete information.

Kustvakt uses SQLite by default, that can be changed with another database, such as MySQL.

Customizing jdbc.properties

Copy jdbc.properties from full/src/main/resources to the full/ directory.

Do not change the filename.

cp full/src/main/resources/jdbc.properties full/

Remove or comment the properties for Sqlite.

Uncomment the setting for MySQL. Customize the jdbc.url, jdbc.username and jdbc.password values.

jdbc.database=mysql
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://[hostname]:[port]/[database-name]?useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
jdbc.username=username
jdbc.password=password
jdbc.schemaPath=db/mysql, db/predefined

jdbc.schemaPath is used for database migration using Flyway and it corresponds to Flyway locations option. By default, the paths are interpreted as classpaths. To point to external directories, use the prefix filesystem, for instance filesystem:sql.

The values of jdbc.schemaPath may have been set to include test data defined in full/src/main/resources/db/test and some user roles defined in full/src/main/resources/db/predefined. You can omit the test data by removing db/test.

You should git ignore this file to prevent pushing database password to github.

Customizing Spring XML configuration

Open full/src/main/resource/default-config.xml.

Search for all occurrences of property name="dataSource", for instance in

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="flyway">
    <property name="dataSource" ref="sqliteDataSource"/>
</bean>

Change the ref attribute in dataSource property to refer to the Spring bean with id c3p0DataSource for all occurrences.

<property name="dataSource" ref="c3p0DataSource" />

While running KustvaktServer or Kustvakt-full-[version].jar, MySQL tables will be created from the SQL files in full/src/main/resources/db/mysql and other paths specified in jdbc.schemaPath.

Advanced Setting

Developer Setting

Search services

Metadata services

Authentication and Authorization services

Client services

Super client services

Plugin services

User services

User group services

Virtual corpus services

Virtual corpus access services

Administrative services

Description services

Clone this wiki locally