I only have application.xml, geronimo-application.xml in the EAR and the ejb-jar.xml in the EJB module.
There is someplace else where I can put it or I must create this openejb-jar.xml ? If so could you give me an example of how it should look like.
Best Regards,
Olivier Voutat
On 2/18/06, Aaron Mulder <
[EMAIL PROTECTED]> wrote:
In ejb-jar.xml you add a resource-ref entry in the section where you
declare your bean, so it looks like this:
<ejb-jar ...>
<enterprise-beans>
<session>
<ejb-name>Foo</ejb-name>
...
<resource-ref>
<res-ref-name>MyDatabase</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>
</enterprise-beans>
</ejb-jar>
Then in your openejb-jar.xml you add a section to point that to a
specific database pool (where ref-name matches res-ref-name in
ejb-jar.xml , and resource-link matches the name of the database pool
as you configured it in the console):
<openejb-jar ...>
<enterprise-beans>
<session>
<ejb-name>Foo</ejb-name>
...
<resource-ref>
<ref-name>MyDatabase</ref-name>
<resource-link>PostgreSQLPool</resource-link>
</resource-ref>
</session>
</enterprise-beans>
</openejb-jar>
Finally, in your EJB code, you look up the data source in JNDI like
this, where the JNDI name is "java:comp/env/" plus the res-ref-name
you used in ejb-jar.xml:
Context ctx = new InitialContext();
Object obj = ctx.lookup("java:comp/env/MyDatabase");
DataSource ds = (DataSource)obj;
Connection con = ds.getConnection();
If you want to access the database pool from a web component like a
servlet, you have to add a similar resource reference to web.xml and a
similar block to resolve it to a database pool to geronimo-web.xml and
the code would look the same.
Thanks,
Aaron
On 2/17/06, Olivier Voutat < [EMAIL PROTECTED]> wrote:
> Thanks Aaron,
>
> This worked perfectly, but now I have a little problem....u made me get
> curious about using a database pool... u see I'm a student of computer
> sciences in Brazil and we use Java as our main programming language. Our
> teacher uses JBoss, and since I knew Geronimo now I call it JBosta (meaning
> Jshit, sorry the word)...
>
> I easily create the database pool but how should I configure my ejb to be
> able to use it ?
>
> David, the tip that Aaron gaved me is very easy to use and works perfectly
> for Jaybird for simple connections.
>
> Olivier
>
>
> On 2/17/06, Aaron Mulder < [EMAIL PROTECTED]> wrote:
> > Ah, I see... If you don't want to use the connection pool then the
> > technique is a little different. You need a <dependency> element in
> > the Geronimo deployment plan for your J2EE module (e.g.
> > geronimo-web.xml for a web app).
> >
> > If you want to know exactly what the dependency element should look
> > like you can go through the database pool screen in the console just
> > like you did and then after you test it hit "Show Plan" instead of
> > deploying the pool, and just take the <depenency> element from out of
> > that plan, and put it in the plan for your J2EE module instead. It's
> > not necessary to go through the console this way, but it'll give you
> > somethign to copy and paste exactly. :) Anyway, it'll be something
> > like this, depending on exactly where you put it in the repository:
> >
> >
> <dependency><url>something/jaybird-full/2.0.1/jar</uri></dependency>
> >
> > Thanks,
> > Aaron
> >
> > On 2/17/06, Olivier Voutat < [EMAIL PROTECTED]> wrote:
> > > Hi again,
> > >
> > > For those who doesn't know, I'm trying to establish a connection
> between my
> > > J2EE application and Firebird Database using Jaybird-2.0.1JDK_1.5.zip
> > >
> http://firebird.sourceforge.net/index.php?op=files&id=jaybird
> > >
> > > (yeah,yeah, I know that Geronimo is only certified for J2EE 1.4 but so
> far
> > > it hasn't be a big issue).
> > >
> > > Extra information: The application that I'm testing already worked
> under
> > > Geronimo using a connection to Firebird through unixODBC without a
> database
> > > pool.
> > >
> > > Thanks everybody who replied. Didn't understand very well your .rar
> issue
> > > David, but anyway here is my situation:
> > >
> > > I wasn't trying to create a database pool to do a connection (it is
> really
> > > necessary ?).
> > > I was trying to make the jaybird-full-2.0.1.jar avaliable to my J2EE.
> > >
> > > Current situation, I created a database pool connection with the
> Database
> > > Type "Other".
> > > In the next config page I put:
> > >
> > > JDBC Driver Class: org.firebirdsql.jdbc.FBDriver
> > > Driver JAR: jaybird-full-2.0.1.jar (deployed in the repository trough
> the
> > > common libraries page)
> > > JDBC Connect URL:
> > >
> jdbc:firebirdsql:localhost/3050:/firebirdData/mydatabase.fdb
> > > DB User Name: *******
> > > DB Password: *******
> > >
> > > After that I did a "Test Connection" and no problem alert was given so
> I
> > > deployed it.
> > >
> > > Deployed my application and it stills gives me the message
> > > ClassNotFoundException...
> > >
> > > Olivier Voutat
> > >
> > >
> > >
> > >
> > > On 2/17/06, David Jencks < [EMAIL PROTECTED]> wrote:
> > > >
> > > > On Feb 16, 2006, at 6:22 PM, Olivier Voutat wrote:
> > > >
> > > > > I'm not getting how to install the driver to make this one
> > > > > avaliable to my applications in Geronimo. Tried many ways, and
> > > > > can't find a way that makes it works. Didn't find any documents
> > > > > about it neither.
> > > > >
> > > > > Can somebody help me about it ?
> > > >
> > > > I tried deploying the latest rar from the downloads, but it has a
> > > > problem in ra.xml (see firebird issue 1433327). I fixed the problem
> > > > in firebird cvs, so if you build the rar yourself it will work.
> > > > (I'll also send you a copy privately). If you want to use something
> > > > closer to the current release, you need to change in ra.xml
> > > >
> > > > <credential-
> > > >
> > >
> interface>javax.resource.security.PasswordCredential </credential-
> > > > interface>
> > > > to
> > > > <credential-
> > > >
> > >
> interface>javax.resource.spi.security.PasswordCredential </credential-
> > > > interface>
> > > >
> > > > and repack the rar.
> > > >
> > > > Anyway, after obtaining a correct rar, you can modify the plan I will
> > > > also send privately to suit your environment and deploy to a running
> > > > server using
> > > >
> > > > java -jar target/geronimo- 1.1-SNAPSHOT/bin/deployer.jar --user system
> > > > --password manager deploy jaybird-2.1.0.rar jaybird-plan.xml
> > > >
> > > > This deployed OK for me but I don't have a firebird installation
> > > > handy so I don't know if there are other problems. Please let me
> > > > know of your progress, I would like there to be a wiki page on using
> > > > firebird/jaybird with Geronimo.
> > > >
> > > > If anyone else would like a copy of the plan I can perhaps get
> > > > started on the wiki page and attach it there.
> > > >
> > > > thanks
> > > > david jencks
> > > >
> > > >
> > > > >
> > > > > Olivier
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Olivier & Cidiane Voutat
> > > Rua Praia de Muriú, 9188
> > > Cep 59092-390 / Natal - RN
> > > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> >
>
>
>
> --
>
> Olivier & Cidiane Voutat
> Rua Praia de Muriú, 9188
> Cep 59092-390 / Natal - RN
> Tel: (84) 3219-0427 Cel: (84) 9977-3917
--
Olivier & Cidiane Voutat
Rua Praia de Muriú, 9188
Cep 59092-390 / Natal - RN
Tel: (84) 3219-0427 Cel: (84) 9977-3917
