Context ctx = new InitialContect();
DataSource ds =
(DataSource)ctx.lookup("java:com/env/jdbc/DBName");
Connection con = ds.getConnection();

--- Scott Van Wart <[EMAIL PROTECTED]> wrote:

> temp temp wrote:
> > My java standalone application wants connection to
> database with lookup  to datasource name which is
> configured in the oc4j app server. 
> >   Please guide me with some ideas to achieve this.
> >   
> You need to bind it yourself, to some provider.  I
> use the DBCP provided 
> with Tomcat (naming-factory-dbcp.jar); the context
> factory is 
> "org.apache.naming.java.javaURLContextFactory"
> (that's not a typo, the 
> class name begins with a lowercase letter). Then you
> create your 
> InitialContext, create sub contexts for each
> component and bind your 
> object to the last context.  DBCP is an in-memory
> one that seems to beat 
> the beta fscontext reference that Sun released.
> 
> Oracle has a class 'com.oracle.naming.J2EEContext'. 
> I suspect that's 
> what OC4J uses.  It also seems to have 
> com.evermind.server.rmi.RMIInitialContextFactory. 
> See if you can find 
> javadocs for those.  If you're grabbing a DataSource
> remotely from a 
> running OC4J instance, I did a quick google search
> and found 
>
http://www.oracle.com/technology/products/ias/toplink/doc/1013/MAIN/_html/cachsyn007.htm
> 
> .. it's for TopLink, but it uses JNDI and follows
> the same conventions 
> that your standalone OC4J (or app server) is going
> to use--JMS or RMI 
> (corba).
> 
> HTH,
>   Scott
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to