Hi ,
in weblogic.properties i have defined connection pool and JNDI name for that connection like ...
weblogic.jdbc.connectionPool.oraclePool=\ url=jdbc:weblogic:oracle,\ driver=weblogic.jdbc.oci.Driver,\ loginDelaySecs=1,\ initialCapacity=4,\ maxCapacity=10,\ capacityIncrement=2,\ allowShrinking=true,\ shrinkPeriodMins=15,\ refreshMinutes=10,\ testTable=dual,\ props=user=ermnetdev;password=ermnetdev;server=ermg
weblogic.jdbc.TXDataSource.oraclePool=oraclePool
one way to get DataSource thru JNDI name oraclePool is
defining resource ref during deployment like
ejb-jar.xml:
<entity>
<ejb-name>Customer</ejb-name>
......
<resource-ref>
<res-ref-name>jdbc/myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
weblogic-ejb.jar.xml:
<weblogic-enterprise-bean>
<ejb-name>Customer</ejb-name>
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/myDB</res-ref-name>
<jndi-name>oraclePool</jndi-name>
</resource-description>
</reference-descriptor>
</weblogic-enterprise-bean>
DataSource ds=(DataSource)context.lookup("java:comp/env/jdbc/myDB");
But i am following a direct route like,
DataSource ds=(DataSource)context.lookup("oraclePool");
it is also working fine(so far i have tested).
My question is
is my way is correct ? how does it differ from the first one ? is there any chance that my way will create any problem in future ?
Thanks in advance .
Regards ,
Ashim Chakraborty
-
Getting DataSource using JNDI in weblogic5.1 (4 messages)
- Posted by: Ashim Chakraborty
- Posted on: March 21 2001 23:55 EST
Threaded Messages (4)
- Getting DataSource using JNDI in weblogic5.1 by Srinivas Janakiraman on March 23 2001 10:53 EST
- Getting DataSource using JNDI in weblogic5.1 by Srinivas Janakiraman on March 23 2001 10:56 EST
-
Getting DataSource using JNDI in weblogic5.1 by Ashim Chakraborty on March 24 2001 01:58 EST
- Getting DataSource using JNDI in weblogic5.1 by Yasha Sable on April 11 2001 11:46 EDT
-
Getting DataSource using JNDI in weblogic5.1 by Ashim Chakraborty on March 24 2001 01:58 EST
- Getting DataSource using JNDI in weblogic5.1 by Srinivas Janakiraman on March 23 2001 10:56 EST
-
Getting DataSource using JNDI in weblogic5.1[ Go to top ]
- Posted by: Srinivas Janakiraman
- Posted on: March 23 2001 10:53 EST
- in response to Ashim Chakraborty
Hi,
your first way is more portable than the second and conforms to J2EE standards.
If you are using the second one and in future want to change the connection to a different pool or change the environment( porting into a new machine) then you are forced to create the pool with the same name and cannot use the existing pool. If you want to use the existing pool you have to change the code.
If you are using the first just changing the weblogic-ejb-jar.xml will do.
Srinivas.J -
Getting DataSource using JNDI in weblogic5.1[ Go to top ]
- Posted by: Srinivas Janakiraman
- Posted on: March 23 2001 10:56 EST
- in response to Srinivas Janakiraman
To add more, these XMLs are like JCLs in mainframes which makes the program portable and can change the file etc., outside the code.
If you dont know about JCL just ignore.
Srinivas.J
-
Getting DataSource using JNDI in weblogic5.1[ Go to top ]
- Posted by: Ashim Chakraborty
- Posted on: March 24 2001 01:58 EST
- in response to Srinivas Janakiraman
Hi thanks for your reply .
Rather than hard coding in the code what i have done is ,
maintaining one cutomdefined class like
public class Utils
{
public static DBJNDINAME = "oraclePool";
}
in my bean class i will be using like
ds = (javax.sql.DataSource)initCtx.lookup(Utils.DBJNDINAME);
My idea is if any changes is required ( due to change of application server settings ) then i will only change the Utils class .
I don't have bother about Bean or XML .
My this idea is working fine in WebLogic 5.1 .
If any body have some better idea , or find any drawback in my idea please mention it .
Thanks in advance
waiting for your ideas and comments.
Ashim Chakraborty -
Getting DataSource using JNDI in weblogic5.1[ Go to top ]
- Posted by: Yasha Sable
- Posted on: April 11 2001 11:46 EDT
- in response to Ashim Chakraborty
How do you register your Utils class with JNDI?