Maven plugin question

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

http://www.theserverlabs.com/blog/2009/05/18/continuous-integration-with-oracle-plsql-utplsql-and-hudson/

The configuration of the plugin is somewhat like

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>sql-maven-plugin</artifactId>
        <version>1.3</version>
 
        <dependencies>
            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc14</artifactId>
                <version>9.0.2.0.0</version>
            </dependency>
        </dependencies>
 
        <configuration>
          <driver>oracle.jdbc.driver.OracleDriver</driver>
          <url>jdbc:oracle:thin:@localhost:1521:xe</url>
          <username>testing</username>
          <password>testing</password>
          <delimiter>/</delimiter>
          <delimiterType>row</delimiterType>
          <keepFormat>true</keepFormat>
        </configuration>
gaurav sharmaAsked:
Who is Participating?
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 ?
0
slightwv (䄆 Netminder) Commented:
Is this not the same as your previous question?

http://www.experts-exchange.com/Programming/Languages/Java/Q_28687432.html
0
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

gaurav sharmaAuthor Commented:
I can share the plugin source here and will really appreciate if somebody can help me !!
0
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.
0
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.INITIAL_CONTEXT_FACTORY, 	
	getDriver());
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)
0

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
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.