Capture Information From Data Source XML File

One Star

Capture Information From Data Source XML File

Hi,
I have the data source XML file (End of this message) in my Talend runtime/deploy folder on my server and it is referred to by the tJDBCConnection component (By checking "Specify a data source alias" and giving the above bean id as the "Data source alias" - please see screenshot below) of my service that is deployed on Talend Runtime.
If the service encounters any errror then it sends an error message using the error handling mechanism I have in place.
The error message contains information regarding job version, payload etc.
I wanted to know if it is possible to capture the information from the property tag with name = url (<property name="url" value="jdbc:sqlserver://Server1:1433;instanceName=Server1;databaseName=OneDB;schema=mySchema;"/>) when the job is executed.
I tried checking "tStatCatcher Statistics" in the Advanced settings tab of tJDBCConnection component but that does not provide information on which server, port, database or schema the tJDBCConnection component is using for connection pooling.
I would greatly appreciate your advice on how to achieve the above.
Data source XML file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlnsSmiley Surprisedsgi="http://www.springframework.org/schema/osgi"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://camel.apache.org/chema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
      http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="jdbcOne" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
  <property name="url" value="jdbc:sqlserver://Server1:3333;instanceName=Server1;databaseName=OneDB;schema=mySchema;"/>
                  <property name="username" value="user"/>
                  <property name="password" value="pass"/>
                  <property name="initialSize" value="10"/>
                  <property name="maxActive"  value="50"/>
                  <property name="maxIdle" value="10"/>
                  <property name="maxWait" value="0"/>
  </bean>
  <osgi:service interface="javax.sql.DataSource" ref="jdbcOne">
    <osgi:service-properties>
            <entry key="osgi.jndi.service.name" value="jdbcOne"/>
    </osgi:service-properties>
  </osgi:service>
</beans>
In tJDBCConnection component Basic tab:

Thanks
Seventeen Stars

Re: Capture Information From Data Source XML File

I would read in this file with a tFileInputXML, set these values with a tJavaRow to context variables and use the context variable to configure the database connection.
The JNDI (container managed database connection) access works only if you deploy the job into a Talend runtime or as war file (webapp). 
One Star

Re: Capture Information From Data Source XML File

Thanks jlolling.
I need to use the JNDI (container managed database connection) as my job is deployed in Talend runtime.
I may change the details within a bean in the Data Source XML file e.g. the database name and therefore I need to find a way to capture information from a bean's (that the tJDBCConnection component is pointing to) property tag with name = url (<property name="url" value="jdbc:sqlserver://Server1:1433;instanceName=Server1;databaseName=OneDB;schema=mySchema;"/>)in the Data Source file whenever my job encounters an error and then save that in a context variable so that the information can be sent as part of the error message to our error queue.
Thanks