Loading

How to configure a DataSource to connect to the AS/400 database?

Publiseringsdato: Mar 2, 2024
Løsning

PROBLEM

You want to connect to the database running in an AS/400 system. Depending on your operating system version, this database can be identified as:
 
  • DB2 for OS/400
  • DB2 for i5/OS
  • DB2 for i
 

SOLUTION

Create a Spring bean to configure a DataSource using the AS400JDBCDriver from the JTOpen Project. The bean definition should look like the example below:

<spring:beans>
  <spring:bean id="as400DataSource"name="as400Bean"class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <spring:property name="url"value="jdbc:as400://SYSTEM/LIBRARY" />
    <spring:property name="driverClassName"value="com.ibm.as400.access.AS400JDBCDriver" />
    <spring:property name="username"value="your_username" />
    <spring:property name="password" value="your_password" />
  </spring:bean>
</spring:beans>


Please note that you must replace SYSTEM/LIBRARY for the values that work in your environment.


JDBC Connector

For the old JDBC Connector, you must add the following configuration element:

<jdbc-ee:connector name="as400DataBaseOldConnector"dataSource-ref="as400DataSource"validateConnections="true"queryTimeout="-1"pollingFrequency="0"doc:name="Database">


DataBase Connector

For the new DataBase Connector, you must create a Generic Database Configuration, as shown below:

<db:generic-config name="as400DataBaseNewConnector"dataSource-ref="as400DataSource"doc:name="Generic Database Configuration"/>


Driver's Classloading

Adding the jt400.jar to the Java Build Path should work, but if you find any issues while running the application, you might need to do the following in Studio:

1 - Right click on the flow you want to run.
2 - Click on Run As -> Run Configurations ...
3 - Click on Classpath tab.
4 - Click on Bootstrap Entries to select it.
5 - Click on button Add External JARs ...
6 - Add jt400.jar
7 - Click on Apply.
8 - Click on Run.


Further References

JTOpen
IBM Toolbox for Java and JTOpen
IBM DB2 for i
 
Knowledge-artikkelnummer

001118877

 
Laster
Salesforce Help | Article