Apache Ant in Batch

Discussions regarding Open Source Java projects under z/OS (other than Tomcat)
Post Reply
robschramm
Posts: 10
Joined: Tue Apr 21, 2009 3:35 am

Apache Ant in Batch

Post by robschramm » Wed Feb 05, 2014 4:53 pm

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?

dovetail
Site Admin
Posts: 1840
Joined: Thu Jul 29, 2004 12:12 pm

Re: Apache Ant in Batch

Post by dovetail » Thu Feb 06, 2014 2:53 pm

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.

robschramm
Posts: 10
Joined: Tue Apr 21, 2009 3:35 am

Re: Apache Ant in Batch

Post by robschramm » Fri Feb 07, 2014 9:52 am

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?

robschramm
Posts: 10
Joined: Tue Apr 21, 2009 3:35 am

Re: Apache Ant in Batch

Post by robschramm » Fri Feb 07, 2014 10:46 am

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.

annieoroberts00
Posts: 1
Joined: Thu Jun 30, 2016 12:25 am

Re: Apache Ant in Batch

Post by annieoroberts00 » Thu Jun 30, 2016 5:56 am

Thanks for the information.

Post Reply