geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Preben Thorø <>
Subject Re: Lookup for Datasource
Date Tue, 06 Dec 2005 08:26:52 GMT
Hi Michael,

there is a very fine example/explanation here:


Ueberbach, Michael wrote:

>I'm using geronimo M5 and have a question about the deploying of an EJB application.
>I already delpoyed a J2EE connector as a global connection to an existing Mysql database.
>Also I deloyed a simple stateless session bean that may be part of a greater EJB application.
>This session bean should retrieve data from the database directly (JDBC for reading).
>I managed to do this while making a lookup to the datasource the following way:
>InitialContext ctx = new InitialContext();
>DataSource ds = (DataSource) ctx.lookup("java:comp/env/MysqlDataSource");
>Here "MysqlDataSource" is the name of the connection defined in the deployment plan for
the above mentioned
>    <name>MysqlDataSource</name>
>Now I would like to replace the name of the connection by a logical name, let's say this
>DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DataSource");
>Therefore a link between the alias "jdbc/DataSource" and the connection "MysqlDataSource"
has to be
>established elswhere.
>I found an example of such a link in the following deployment plan
>        xmlns=""
>        xmlns:naming=""
>        configId="PhoneBookWeb"
>        parentId="MysqlDatabase"
>        >
>    <naming:resource-ref>
>        <naming:ref-name>jdbc/DataSource</naming:ref-name>
>        <naming:resource-link>MysqlDataSource</naming:resource-link>
>    </naming:resource-ref>
>But this is the plan for a web application and I want to deploy a simple EJB application.
>neccessary openejb-jar.xml does not allow such a link.
>So where to put it?
>Thanks a lot

View raw message