File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to access a datasource from ant?

 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic