This tutorial describes how to change the database which is used by the EDB to persist OpenEngSBModels.
The time needed to perform this task depends heavily on which database you want to use instead of the standard H2 database and on your experience with the OpenEngSB. This chapter will list the different possibilities from the shortest time period needed to the most complex one. If you are not familiar with the OpenEngSB please read this manual from the start or check the homepage for further information.
If you want to replace the standard database with another JPA supported database (supported databases listet here), the procedure of changing is rather simple. You have to change the properties for the database connection of the "infrastructure/jpa" bundle. This is done by changing the config file "org.openengsb.infrastructure.jpa.cfg". This file is in the "assembly/src/main/filtered-resources/etc" folder. The file has the following entries:
driverClassName=[here shall be the name of your driver class name, example: org.h2.jdbcx.JdbcDataSource] url=[here shall be the url to the used database file, example: jdbc:h2:openengsb] username=[here shall be the username for authentication at the database] password=[here shall be the password for authentication at the database]
After changing of this file, you have to assure that the driver which shall be used by the data source is loaded at runtime. For that you have to load the database driver before the connection to the database is established. Your database bundle dependency should be added to the "parents/shared/pom.xml" file. A dependency entry for the h2 database looks like this (the h2.version is defined as property in the same file:
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.3.163</version> </dependency>
After you added the dependency, you have to make sure the database is loaded before the database connection is established. For that just replace following code line in the file "assembly/src/main/filtered-resources/features.xml" with the new database driver bundle (as you can see you only have to copy and paste the values of the dependency):
After this steps, you are done and the EDB uses now the new database as persistence backend.
If you want to replace the standard database with another non JPA supported database you will have to change first the data source like described in the previous section. After that you have to write your own bundle that provides the EngineeringDatabaseService. In this case you also have to reproduce all SQL commands and port it for the new database and replace the standard EngineeringDatabaseService.