Member-only story
Springboot JPA with IBMi AS400 : The Datasource
When first stepping into my current position working with the AS400, I had a team mate tell me that you could not do JPA on the IBMi.
I took this as a challenge.
And so I thought I would take the time today to share what I was able to do…
The DatasourceConfig
The first thing you will want to do is manually configure your datasource. You will want to do this because the JT400 dependency requires you to implement in a specific way.
First we start with the datasource outline…
import com.ibm.as400.access.*;
@Configuration
@EnableJpaRepositories(
basePackages = "com.example.repository.dev",
entityManagerFactoryRef = "entityManagerFactory",
transactionManagerRef = "transactionManager"
)
public class DatasourceConfig {
...
}You will obviously need for imports than this but the as400 import is the most important.
The AS400 Object
Next we add the AS400 as an object…
@Bean
public AS400 AS400() throws Exception {
char[] password = datasourceProperties.getPassword().toCharArray();
AS400 ibmi = new AS400("10.100.0.1", datasourceProperties.getUsername(), password);
try {
ibmi.setThreadUsed(true);
ibmi.setGuiAvailable(false); //<- tells AS400 we don't have a terminal to respond with
ibmi.setLocale(java.util.Locale.US)…









