geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ueberbach, Michael" <michael.ueberb...@dbh.de>
Subject AW: Lookup for Datasource
Date Tue, 06 Dec 2005 09:07:12 GMT
Hi Preben,

thanks for your hint. I think this will help.
Michael

-----Ursprüngliche Nachricht-----
Von: Preben Thorø [mailto:pto@trifork.com]
Gesendet: Dienstag, 6. Dezember 2005 09:27
An: user@geronimo.apache.org
Betreff: Re: Lookup for Datasource


Hi Michael,

there is a very fine example/explanation here:
http://www.openejb.org/faq_openejb-jar.html

Regards
Preben


Ueberbach, Michael wrote:

>hello,
>
>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
>connector:
>
>(...)
><connectiondefinition-instance>
>    <name>MysqlDataSource</name>
>(-...)
>
>Now I would like to replace the name of the connection by a logical name, let's say this
way:
>
>(...)
>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
>
><web-app
>        xmlns="http://geronimo.apache.org/xml/ns/web/jetty"
>        xmlns:naming="http://geronimo.apache.org/xml/ns/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>
></web-app>
>
>But this is the plan for a web application and I want to deploy a simple EJB application.
The
>neccessary openejb-jar.xml does not allow such a link.
>So where to put it?
>
>Thanks a lot
>Michael
>  
>

Mime
View raw message