ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: JNDI , WebSphere Datasource question
Date Sat, 11 Jun 2005 14:38:01 GMT
I'm trying to figure out why in the world you would need your
application to pass values that should be configured on the server
level. This seems like you are looking to the wrong place to solve
this. you need to configure the u/p on the server level. iBatis does
not support passing any values to JNDI because that is not how JNDI
works and iBatis does not have it's own JNDI implementation. It is
only meant to reference a JNDI context.

I suppose if you really need this to be on the application side you
could create your own TransactionManager by writing and implementation
of the Transaction interface and using the JdbcTransaction as a guide
to create you own. You would need to change all getConnection() to
getConnection(username,password) and you would need to figure out how
to get the u/p to it.

Another option would be to wrap the JNDI supplied DataSource with your
own DataSource implementation within a custom DataSourceFactory. You
would have to spin your own DataSourceFactory and DataSource wrapper.
Your DataSource wrapper could receive values from <property> tags that
are used in your DataSourceFactory config. you could make a call to
the getConnectin(username,password) on the real DataSource while
hiding it behind the getConnection() of your wrapper/proxy. You can
store the values from the username and password that you configured on
the wrapper DataSource and then when there is a call to the
getConnection() on the wrapper it would do something like...

public Connection getConnection() {
return wrappedDataSource.getConnection(this.username,this.password);
}

Now to me... all of this seems SUPER unnecessary. But, if you
wanna...be my guest.

If you don't need to use JNDI you could always use the SIMPLE data
source factory and setup all you database connection information
there.

Brandon

On 6/11/05, max_lazzari@tiscali.it <max_lazzari@tiscali.it> wrote:
> The JNDI Datasource is configured on the WebSphere AS without username and
> password, so I need to pass them. I know that the right way to reference
> an existing JNDI datasource is the following one:
> 
>  transactionManager type="JDBC"
>     dataSource type="JNDI"
>        property name="DataSource" value="jdbc/JDEdb"/
>    /dataSource
>  /transactionManager
> 
> What I'm looking for is a way to pass, even programmatically, username and
> password (that always the same couple for all users using the application).
> 
> Is it possible to reference by definition the JNDI Datasource and then programmatically
> set username and password?
> 
> thx
> 
> 
> >-- Messaggio Originale --
> >Reply-To: ibatis-user-java@incubator.apache.org
> >Date: Thu, 9 Jun 2005 09:57:05 -0400
> >From: Andy Thompson <arthomps@gmail.com>
> >Reply-To: Andy Thompson <arthomps@gmail.com>
> >To: ibatis-user-java@incubator.apache.org,
> >       Brandon Goodin <brandon.goodin@gmail.com>
> >Subject: Re: JNDI , WebSphere Datasource question
> >
> >
> >what brandon said.  but i suspect that what you're looking for is
> >somethign like:
> >
> >       <transactionManager type="EXTERNAL" >
> >               <dataSource type="JNDI">
> >            <property name="context.java.naming.factory.initial"
> >value="weblogic.jndi.WLInitialContextFactory"/>
> >            <property name="context.java.naming.provider.url"
> >value="t3://localhost:7001"/>
> >            <property name="DataSource" value="poolName.pool"/>
> >               </dataSource>
> >       </transactionManager>
> >
> >where poolName.pool is the name of your pool.
> >
> >On 6/9/05, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> >> That is not an option because that is not how JNDI works. Are you
> >> saying that you need to pass a username/password to your datasource
> >> for each individual user or do you simply want to configure it
> >> dynamically for the whole application? If it is the latter then you
> >> are trying to configure your JNDI on the wrong level. iBatis is simply
> >> referencing an already configured JNDI context.
> >>
> >> Brandon
> >>
> >> On 6/9/05, max_lazzari@tiscali.it <max_lazzari@tiscali.it> wrote:
> >> > Hi,
> >> > I'm using iBatis sqlMap in a J2ee application to be deployed on WebSphere
> >> > AppServer 5.1.
> >> >
> >> > We have to use a JNDI Datasource which needs for username and password.
> >> >
> >> > How can I configure the Transaction Manager?
> >> >
> >> > Is the following an option?
> >> >
> >> > ----------------------------------------------
> >> > transactionManager type="JDBC"
> >> >    dataSource type="JNDI"
> >> >       property name="DataSource" value="jdbc/JDEdb"/
> >> >       property name="JDBC.Username" value="${username}"/
> >> >       property name="JDBC.Password" value="${password}"/
> >> >    /dataSource
> >> > /transactionManager
> >> >
> >> > ----------------------------------------------
> >> >
> >> >
> >> > Thanks in advance,  rgrds
> >> >
> >> > Max
> >> >
> >> >
> >> > __________________________________________________________________
> >> > TISCALI ADSL 1.25 MEGA a soli 19.95 euro/mese
> >> > Solo con Tiscali Adsl navighi senza limiti di tempo
> >> > a meno di 20 euro al mese e in piu' telefoni senza
> >> > pagare il canone Telecom. Scopri come
> >> > http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >--
> >Andrew R. Thompson
> >Currently in D.C. Consulting
> 
> 
> __________________________________________________________________
> TISCALI ADSL 1.25 MEGA a soli 19.95 euro/mese
> Solo con Tiscali Adsl navighi senza limiti di tempo
> a meno di 20 euro al mese e in piu' telefoni senza
> pagare il canone Telecom. Scopri come
> http://abbonati.tiscali.it/adsl/sa/1e25flat_tc/
> 
> 
> 
>

Mime
View raw message