Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This is an example of a JSP-page calling an Enity Bean that uses container managed persistence (CMP). The result looks like this:

Image Added

If you have read my former mini example about the time bean, then you already know that can't spell. I hope you can understand it anyway.

...

Anyhow, I have a table in my derby database that I called phonebook. I started by using the DBManager in the geronimo console ( http://localhost:8080/console/portal/internalDB/internalDB_DBManager ) And created a new database that I called PhonebookDB.

Image Added

Then I created the table and put some values in the table using these SQL statements.

Code Block
sql
sql
create table phonebook (name varchar(15) primary key, number varchar(15)) ;
insert into phonebook values('Mattias', '1234');
insert into phonebook values('Pamela', '5678');

Image Added

This EJB application searches for numbers when the user enters names.

...

Now, let's use the pool wizard again as described earlier, but this time, make a mysql pool by selecting "Database Type": MySQL. I can't rembember if the JDBC driver comes default or if you would have to download it by simply clicking the button "Download driver". Fill in "phone" as user name and "book" as password.

Image Added

You should end up with a database pool file like this. I save it with the name mysql_PhonebookPool.xml in the same directory as the former derby_PhonebookPool.xml :

...

Now we should be able to find Cindy's phone number to prove that we are really using the mysql database. This picture shouws this:

Image Added

--------------------------------------------------------------------------------
By Mattias Malmgren mattias@freefarm.se ( I am putting my e-mailaddress there so you can send e-mails to me if you want to, so feel free to do so! I am a very lonley person so an e-mail would chear me up.)
2006-09-30