Obtaining a Connection Factory


Connection factories are obtained from JNDI in the usual way. The resource adaptor, when it is deployed, is stored in JNDI under a name that is specified during deployment. The JDO vendor usually provides a default name. Getting the name right is the only hard part. The code, shown in Listing 6-5, is straightforward. After getting a connection factory, the application obtains a persistence manager as shown in Listing 6-1.

Listing 6-5: Finding a ConnectionFactory in JNDI

start example
 String cfName = "someName"; // examples: "java:/kodo", "java:comp/env/eis/MyJDO" ConnectionFactory cf = null; try    {    cf = (ConnectionFactory) new InitialContext().lookup(cfName);    } catch (NamingException ne)    {    // handle exception ...    } 
end example




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net