[resolved] JDBC connection pool to AS400

One Star

[resolved] JDBC connection pool to AS400

Hello All,
I am trying to create jdbc connection pool to AS400 db in talend runtime. My datasouce configuration file looks as follows and it deploys fine in runtime:
<bean id="poolDataSource" class="com.ibm.as400.access.AS400JDBCConnectionPoolDataSource">
    <property name="serverName" value="XXX"/>
    <property name="user" value="XXX"/>
    <property name="password" value="XXX"/>
  </bean>
 
  <bean id="dataSource"
        class="com.ibm.as400.access.AS400JDBCConnectionPool" destroy-method="close">
        <property name="dataSource" ref="poolDataSource" />
        <property name="maxConnections" value="3" />
       
    </bean>
 
  <service ref="dataSource" auto-export="class-hierarchy">
    <service-properties>
            <entry key="osgi.jndi.service.name" value="jdbc-as400CPds"/>
    </service-properties>
  </service>
The reason I have to do it this way is because AS400JDBCConnectionPoolDataSource does not handle connection pool functionality (for example, I cannot set number of connections). AS400 jar has its own connection pool class: AS400JDBCConnectionPool which unfortunately does not implement javax.sql.DataSource interface, although it has both required getConnection methods. That's why I try to expose this service under its own class. Unfortunately it seems that my talend job does not like this setup. When I run it, in the log file I see this line: Bundle local_project1.RestWSPrototype3 is waiting for dependencies . Can I somehow configure my job to look for objectClass = AS400JDBCConnectionPool rather then DataSource? Any other advice on how I can setup jdbc connection pool to AS400?
Thank you!
Svetlana

Accepted Solutions
One Star

Re: [resolved] JDBC connection pool to AS400

OK, solved it! In case anybody interested, I used apache connection pool: org.apache.tomcat.jdbc.pool.DataSource. So my final configuration is:
<bean id="as400poolDS" class="com.ibm.as400.access.AS400JDBCConnectionPoolDataSource">
    <property name="serverName" value="XXX"/>
    <property name="user" value="XXX"/>
    <property name="password" value="XXX"/>
  </bean>
 
 
  <bean id="dataSource"
        class="org.apache.tomcat.jdbc.pool.DataSource" >
        <property name="dataSource" ref="as400poolDS" />
       
        <property name="initialSize" value="2" />
        <property name="maxActive" value="3" />
       
    </bean>
 
  <service ref="dataSource" interface="javax.sql.DataSource">
    <service-properties>
            <entry key="osgi.jndi.service.name" value="jdbc-as400CPds"/>
    </service-properties>
  </service>

All Replies
One Star

Re: [resolved] JDBC connection pool to AS400

OK, solved it! In case anybody interested, I used apache connection pool: org.apache.tomcat.jdbc.pool.DataSource. So my final configuration is:
<bean id="as400poolDS" class="com.ibm.as400.access.AS400JDBCConnectionPoolDataSource">
    <property name="serverName" value="XXX"/>
    <property name="user" value="XXX"/>
    <property name="password" value="XXX"/>
  </bean>
 
 
  <bean id="dataSource"
        class="org.apache.tomcat.jdbc.pool.DataSource" >
        <property name="dataSource" ref="as400poolDS" />
       
        <property name="initialSize" value="2" />
        <property name="maxActive" value="3" />
       
    </bean>
 
  <service ref="dataSource" interface="javax.sql.DataSource">
    <service-properties>
            <entry key="osgi.jndi.service.name" value="jdbc-as400CPds"/>
    </service-properties>
  </service>
Highlighted
Moderator

Re: [resolved] JDBC connection pool to AS400

Hi zvers,
Thanks for posting that you resolved it by yourself and sharing your solution with us.

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.