Page 1 of 1

Apache Ant in Batch

Posted: Wed Feb 05, 2014 4:53 pm
by robschramm
I am running Apache Ant on z/OS to perform JDBC connections in batch to DB2 LUW. As part of the Ant buildfile, I am using the Ant Tasks SQL which has an optional parameter of "ouput" which I have used to direct the output to a file. If "output" is not used, any output goes to STDOUT. Should I be able to use something like output="//DD:TESTOUT" instead of the output="/u/user/somefile.txt"

Here is the section from the buildfile.

Code: Select all

<sql                                                      
    driver="com.ibm.db2.jcc.DB2Driver"                    
    url="jdbc:db2://servername:50000/database"               
    userid="someuser"                                     
    password="password"                                  
    print="yes"                                           
    failOnConnectionError="true"                          
    output="/u/user/somefile.txt"                                 
    onerror="continue">                                   
    <transaction src="/u/user/test.sql"/>     
    <classpath>                                           
       <pathelement location="/opt/db2luw/db2jcc4.jar"/>  
    </classpath>                                          
 </sql>                                                   
Here is the verbose message

Code: Select all

9.2/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file                                          
     [echo] Database Connection Test                                                                      
      [sql] connecting to jdbc:db2://servername:50000/database                                               
      [sql] Loading com.ibm.db2.jcc.DB2Driver using AntClassLoader with classpath /opt/db2luw/db2jcc4.jar 
      [sql] Opening PrintStream to output Resource [b]/DD:TESTOUT [/b]                                           
      [sql] 0 of 0 SQL statements executed successfully                                                   
BUILD SUCCESSFUL                                                                                          
Notice that the //DD:TESTOUT becomes /DD:TESTOUT. Bug with Ant?

Re: Apache Ant in Batch

Posted: Thu Feb 06, 2014 2:53 pm
by dovetail
I don't believe so.

I assume that this Ant task will use classes in the standard java.io package, which do not support MVS data set or DD names.

On z/OS Java, you can use com.ibm.jzos classes to write to DD or data set names, but there is little chance that your Ant class with support this.

Re: Apache Ant in Batch

Posted: Fri Feb 07, 2014 9:52 am
by robschramm
I had thought that the zfile would extend the java.io .. possibly get control first. I understand where I started getting confused. I was looking at the FileFactory and read the note about the "//" processing and that it would continue on to other file types if it wasn't a DD or Dataset. I am sure that some wishful thinking on my part was also part of it.

Is there a way to repackage or override the java.io.file to use the com.ibm.jaos classes. It seems like it would make java a whole lot more useful on z/OS.

I am guessing that there isn't an easy way to do it.. otherwise you "dovetail" would have already done it.

This next suggestion is even weirder. Would it be possible to modify the Ant build to replace all occurances of java.io.file with the jzos classes such that it would be a one-to-one replacement? As long as it was something one-to-one, it could be worked into a platform dependent build for Ant to implement the altered classes. Or would be possible to extend the java.io.file to allow for the "//" processing?

Re: Apache Ant in Batch

Posted: Fri Feb 07, 2014 10:46 am
by robschramm
After doing some additional reading.. it looks like I might be better off trying to extend existing Ant class(es). I will ask some questions on the ant developer list. Perhaps there are some strategic classes that could be extended to use FileFactory when there is a "//" in the beginning of a filename.

Re: Apache Ant in Batch

Posted: Thu Jun 30, 2016 5:56 am
by annieoroberts00
Thanks for the information.