Maven plugin question

I am using a sql maven plugin which runs scripts to a DB. Below is the concept I am implementing.

The configuration of the plugin is somewhat like

gaurav sharmaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gaurav sharmaAuthor Commented:
Instead of the username and password in the above pom.xml, I have to use a JNDI connection which is set up on websphere to connect to the database above. The maven execution is done on a remote machine ..not on server where websphere is installed. What would need to be done to accomplish this change ?
slightwv (䄆 Netminder) Commented:
Is this not the same as your previous question?
gaurav sharmaAuthor Commented:
Yes. It is the same question. I am a java newbie and have no idea on how to write a plugin. Wanted to get some guidance about how to go about making this change. I already use the password in the settings.xml.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

gaurav sharmaAuthor Commented:
I can share the plugin source here and will really appreciate if somebody can help me !!
slightwv (䄆 Netminder) Commented:
If the other question didn't provide an answer, you should not have accepted an answer.  Clicking 'Request Attention' will have a Moderator see if they can find additional Experts.

If the question wasn't asked properly, then you should delete the question and ask it again.

In this case, it is pretty much the same question.  I don't see how it changed.

If you didn't get an answer there, what makes you think asking it again will work?

The same Experts watch the same Topic Areas so we all have seen the original question as well as this question.  Asking it again doesn't really accomplish anything.

Sorry but I'm an Oracle person.  Cannot help with Java or Plug-Ins.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
I still recommend what I said in the previous question (ie. using the settings.xml or environment to configure this) but anyway, if you must, this is about all the guidance that I could provide...

Looking at the source code (from GrepCode) around lines 893 to 909 is where the Connection object is established from the driver and url parameters. You would need to replace that with code that gets a connection from JNDI. And the fact that this is not running on the same server as Websphere is only going to make your life even harder, but something like this might work...

Properties env = new Properties();
env.put(Context.PROVIDER_URL, getUrl());
Context context = new InitialContext(env);
Connection conn = (Connection) context.lookup("YOUR_CONNECTION_OBJECTS_NAME");

Open in new window

Things that you'll have to work out...

- How to compile this and install it locally so Maven will know to run you version rather than the standard version.
- How/where to put the Websphere jars that will be required to access the JNDI resources
- The above code uses the existing driver and url properties from the POM to specify the JNDI InitialContextFactory to use (this is a Websphere specific class) and the JNDI provider url to use to connect to your websphere server. Depending on your websphere setup you may even still need a username/password to do the JNDI connect and if so, you could use the existing username/password parameters to populate the right "env" Properties in the code above to set those.
- What the value of YOUR_CONNECTION_OBJECTS_NAME that you would need to put into the code above to get the correct object from JNDI.
- Is it actually a Connection object that websphere has configured? Or is it actually a DataSource object that can supply Connection objects? If so, you would need to modify the above to get the DataSource and then call .getConnection() on that DataSource.

Good luck !!    (I'll say again though, I wouldn't recommend going this fairly "advanced" way, just use the simple properties that I mentioned earlier)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.