struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Van Wart <sc...@indosoft.com>
Subject Re: [JAVA]How to get datatbase connection from lookup to datatsource name in a standalone java application
Date Thu, 24 Aug 2006 20:35:27 GMT
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message