Friday, July 30, 2010

Get value from SQL into an Ant property

Recently I had to adjust some of our JMS configuration and needed make sure we set the ServerPeerID configuration value to a unique value among our servers. We have a unique server number in our database so I figured that I would just use that value. In order to do this, I needed to get the database value into an Ant property, which is then used to generate the configuration file, which includes the ServerPeerID. Below is the Ant task and steps I used to do this.

Steps:
  1. Define where the SQL results will be written
  2. Make sure the file does not already exist
  3. SQL task to get the result
  4. Load the file back into a property
  5. Use the propertyregex task to strip out just the unique number

Warning: The syntax highlighter appears to be reformatting my XML and not allowing the self closing tags. Probably my problem but you should be able to get the idea from the


   
   
   
      
      SELECT PREF_VALUE FROM PREFERENCE WHERE PREFERENCE_ID = 71;                
    
     
    
    

No comments:

Post a Comment