Edit the pom.xml file in the root of your project, there add the next dependency inside the <dependencies> part:
<dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400</artifactId>
<version>21.0.7</version>
</dependency>
Maybe the above code is already in your pom.xml but commented, in that case just uncomment it.OpenXava 8.0 or later (Spring Boot): Edit src/main/resources/application.properties of your project to adjust the datasource to point to AS/400, something like this:
spring.datasource.username=java
spring.datasource.password=ao49fmsk
spring.datasource.url=jdbc:as400:192.168.1.8/mylib
spring.datasource.driver-class-name=com.ibm.as400.access.AS400JDBCDriver
Instead of 192.168.1.8 you should put the IP of your AS/400 and instead of mylib the name of the library where your tables are in your AS/400. Also put the correct username and password. Don't forget to comment or remove the datasource entries for HSQLDB (the default one when you create a new OpenXava project), only one datasource should be active.
OpenXava 7.x or earlier: Edit src/main/webapp/META-INF/context.xml of your project to adjust the datasource to point to AS/400, something like this:
<Resource name="jdbc/MyAppDS" auth="Container"
type="javax.sql.DataSource"
maxTotal="100" maxIdle="20" maxWaitMillis="10000"
username="java" password="ao49fmsk"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"
url="jdbc:as400:192.168.1.8/mylib"/>
The differences are the driverClassName and the url. Obviously, instead of 192.168.1.8 you should put the IP of your AS/400 and instead of mylib put the name of the library where your tables are in your AS/400. Also put the correct username and password. Maybe the above code is already in your context.xml but commented, in that case just uncomment it. Don't forget to comment or remove the datasource for HSQLDB (the default one when you create a new OpenXava project), only one datasource (with the same name) should be active.
CRTJRNRCV JRNRCV(MYLIB/MYRCV) THRESHOLD(5000)
CRTJRN JRN(MYLIB/MYJRN) JRNRCV(MYLIB/MYRCV) MNGRCV(*SYSTEM)
CHGJRN JRN(MYLIB/MYJRN) JRNRCV(*GEN) DLTRCV(*YES)
STRJRNPF FILE(MYLIB/*ALL) JRN(MYLIB/MYJRN) IMAGES(*BOTH) OMTJRNE(*OPNCLO)
STRJRNPF FILE(MYLIB/MYTABLE) JRN(MYLIB/MYJRN)
After the changes you have to rebuild your project. In OpenXava Studio click with right mouse button on your project an choose Run As > Maven install, thus:
Or if you have Maven installed in your computer and you prefer to use command line:
$ cd myapp
$ mvn install
Optimization note: Instead of a mvn install, that do a complete Maven build, you can use mvn war:exploded, enough to apply the above changes for development. You can run mvn war:exploded from OpenXava Studio with Run As > Maven build... and typing war:exploded for goal.
Run your application, it should work nicely against your IBM i. If it fails, verify that the user and password in your datasource configuration (application.properties in 8.0+, context.xml in 7.x) are correct, that the server IP is correct. Also verify that the journal has been created and the tables added to it, as explained above.
If it still fails ask us in the OpenXava Help forum. Include the content of your persistence.xml, your datasource configuration (application.properties in 8.0+, context.xml in 7.x) (remove the passwords) and specially the stacktrace produced, you can find the trace in the Console tab of OpenXava Studio.
If your Java application is running on a Windows Server and you are experiencing performance issues, it may not necessarily be an issue with the AS/400 but rather a network configuration problem on the Windows Server. Don't worry, the problem is easy to fix, simply add the parameter tcp no delay=true to the database connection URL. That is, the definition of the data source could be:
In OpenXava 8.0+ edit your application.properties:
spring.datasource.url=jdbc:as400:192.168.1.8/mylib;tcp no delay=true
In OpenXava 7.x edit your context.xml:
<Resource name="jdbc/MyAppDS" auth="Container"
type="javax.sql.DataSource"
maxTotal="100" maxIdle="20" maxWaitMillis="10000"
username="java" password="ao49fmsk"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"
url="jdbc:as400:192.168.1.8/mylib;tcp no delay=true"/>
Note the tcp no delay=true at the end of the URL.
When you use OpenXava with HSQLDB (the default), the launcher class includes a line DBServer.start() to start the database. Since you're now using AS/400, this line is no longer needed. You can comment or remove it to improve startup performance:
OpenXava 8.0 or later (Spring Boot): Launcher class in root package (myapp)
@SpringBootApplication
public class MyApplication extends OpenXavaApplication {
public static void main(String[] args) throws Exception {
// DBServer.start("myapp-db"); // Comment or remove, HSQLDB no longer needed
SpringApplication.run(MyApplication.class, args);
}
}
OpenXava 7.x or earlier: Launcher class in run package
public class myapp {
public static void main(String[] args) throws Exception {
// DBServer.start("myapp-db"); // Comment or remove, HSQLDB no longer needed
AppServer.run("myapp");
}
}