• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to access a datasource from ant?

 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got an ant build file with a "db" target that creates a fresh new database. This currently uses a sql task to drop and create tables. The connection is made by specifying the driver, url, userid, and password. Works fine. However now I need to modify this to use a datasource instead. I have the JNDI name of the datasource, but the sql task doesn't seem to support connecting via JNDI. Am I missing something here? Is there some other way in an ant script to connect to a datasource and execute some arbitrary SQL statements?

I could write a Java class that opens the connection I suppose. But it seems like I wouldn't be the first person to want to do something like this, so I suspect there's another way. Anyone?

Ah, with a bit more research I see that here Roseanne mentions having the same problem a few years ago and writing a custom task. Roseanne, is that code available anywhere? Or has any other solution arisen since then?
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All right, I was able to get hold of traditional JDBC connection info I can use instead: URL, username, password. Seems odd though that using a datasource isn't supported here. Oh well.
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I might be able to find the code, but probably it will not be very useful for you, since I wrote a customized encrypted JNDI, and it was in a huge system, with a lot configuration files.

However, I will try to have a look tonight. It is good for me to review what I did too. If I can extract something simple and useful, I will let you have it.
 
please buy this thing and then I get a fat cut of the action:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic