You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by ru...@northwesternmutual.com on 2007/05/17 00:31:07 UTC

Setting username and password credentials for JNDI datasource

> My DataSources need to have their Connection's username and password
> credentials set programmatically at runtime.  Unfortunately, for a few
> reasons, configuring them at the server level is not an option.
> 
The most recent postings I was able to find on this subject were from
2005, so I wanted to put this message out there again, in case there is
a solution supported in iBATIS now, or at least an elegant workaround,
that someone else has found.

> I am able to do the following in Hibernate, and am looking for the
> equivalent way to accomplish this in iBATIS:
> 
>     Configuration config = new
> Configuration().configure("hibernate.cfg.xml");
>     config.setProperty("hibernate.connection.username", "username");
>     config.setProperty("hibernate.connection.password", "password");
> 
> thanks
> - Russ
> 
> 
> 
</pre><font face=Arial>This e-mail and any attachments may contain confidential information of Northwestern Mutual. If you are not the intended recipient of this message, be aware that any disclosure, copying, distribution or use of this e-mail and any attachments is prohibited. If you have received this e-mail in error, please notify Northwestern Mutual immediately by returning it to the sender and delete all copies from your system. Please be advised that communications received via the Northwestern Mutual Secure Message Center are secure. Communications that are not received via the Northwestern Mutual Secure Message Center may not be secure and could be observed by a third party. Thank you for your cooperation.</font><pre>

RE: Setting username and password credentials for JNDI datasource

Posted by ru...@northwesternmutual.com.
Right now, I just have the basic configuration going on, and am applying
the credentials to the connection later, so my SqlMapClient creation
isn't anything special.

My SqlMapConfig.xml contains the following:

	<transactionManager type="EXTERNAL" >
		<dataSource type="JNDI">
			<property name="DBJndiContext"
value="java:comp/env/jdbc/zimbubnk" />
		</dataSource>
	</transactionManager> 


And I'm creating the SqlMapClient with the following code:

Reader reader = 
	Resources.getResourceAsReader
(
	"/com/nm/ecc/persistence/data/singletable/SqlMapConfig.xml"
);

SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);


-----Original Message-----
From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf
Of Larry Meadors
Sent: Wednesday, May 16, 2007 10:15 PM
To: user-java@ibatis.apache.org
Subject: Re: Setting username and password credentials for JNDI
datasource

How are you creating your sql map client?

Larry


On 5/16/07, russengel@northwesternmutual.com
<ru...@northwesternmutual.com> wrote:
>
>
>
> My DataSources need to have their Connection's username and password
> credentials set programmatically at runtime.  Unfortunately, for a few
> reasons, configuring them at the server level is not an option.
>
> The most recent postings I was able to find on this subject were from
2005,
> so I wanted to put this message out there again, in case there is a
solution
> supported in iBATIS now, or at least an elegant workaround, that
someone
> else has found.
>
> I am able to do the following in Hibernate, and am looking for the
> equivalent way to accomplish this in iBATIS:
>
>     Configuration config = new
> Configuration().configure("hibernate.cfg.xml");
>     config.setProperty("hibernate.connection.username", "username");
>     config.setProperty("hibernate.connection.password", "password");
>
> thanks
> - Russ
>
>  This e-mail and any attachments may contain confidential information
of
> Northwestern Mutual. If you are not the intended recipient of this
message,
> be aware that any disclosure, copying, distribution or use of this
e-mail
> and any attachments is prohibited. If you have received this e-mail in
> error, please notify Northwestern Mutual immediately by returning it
to the
> sender and delete all copies from your system. Please be advised that
> communications received via the Northwestern Mutual Secure Message
Center
> are secure. Communications that are not received via the Northwestern
Mutual
> Secure Message Center may not be secure and could be observed by a
third
> party. Thank you for your cooperation.
>
>

This e-mail and any attachments may contain confidential information of Northwestern Mutual. If you are not the intended recipient of this message, be aware that any disclosure, copying, distribution or use of this e-mail and any attachments is prohibited. If you have received this e-mail in error, please notify Northwestern Mutual immediately by returning it to the sender and delete all copies from your system. Please be advised that communications received via the Northwestern Mutual Secure Message Center are secure. Communications that are not received via the Northwestern Mutual Secure Message Center may not be secure and could be observed by a third party. Thank you for your cooperation.

Re: Setting username and password credentials for JNDI datasource

Posted by Larry Meadors <lm...@apache.org>.
How are you creating your sql map client?

Larry


On 5/16/07, russengel@northwesternmutual.com
<ru...@northwesternmutual.com> wrote:
>
>
>
> My DataSources need to have their Connection's username and password
> credentials set programmatically at runtime.  Unfortunately, for a few
> reasons, configuring them at the server level is not an option.
>
> The most recent postings I was able to find on this subject were from 2005,
> so I wanted to put this message out there again, in case there is a solution
> supported in iBATIS now, or at least an elegant workaround, that someone
> else has found.
>
> I am able to do the following in Hibernate, and am looking for the
> equivalent way to accomplish this in iBATIS:
>
>     Configuration config = new
> Configuration().configure("hibernate.cfg.xml");
>     config.setProperty("hibernate.connection.username", "username");
>     config.setProperty("hibernate.connection.password", "password");
>
> thanks
> - Russ
>
>  This e-mail and any attachments may contain confidential information of
> Northwestern Mutual. If you are not the intended recipient of this message,
> be aware that any disclosure, copying, distribution or use of this e-mail
> and any attachments is prohibited. If you have received this e-mail in
> error, please notify Northwestern Mutual immediately by returning it to the
> sender and delete all copies from your system. Please be advised that
> communications received via the Northwestern Mutual Secure Message Center
> are secure. Communications that are not received via the Northwestern Mutual
> Secure Message Center may not be secure and could be observed by a third
> party. Thank you for your cooperation.
>
>