Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Subscription to WebLogic Pro

email article
printer friendly
get the code

Create CMR/CMP Entity Beans
Deploy entity beans to configure a server and import a database structure
by Olexiy Prokhorenko and Alexander Prohorenko

February 24, 2005

As you likely already know, Enterprise JavaBeans (EJBs) constitute a powerful, flexible technology that gives the developer significant advantages during the development process. However, it is not easy to learn, particularly for the beginning of the design and preparation of applications. The same is true for Container-Managed Relationship (CMR) and Container-Managed Persistence (CMP). Of course, once configured and working, development with these technologies becomes more pleasurable.

ADVERTISEMENT

Creating even small applications demands attention to and knowledge of the configuration of the application server, as well as the EJBs themselves. At present a lot of GUI tools for automatic creation of configuration files and for importing existing structures of databases exist; however, to feel a little more confident in the whole process, and for solving problems, it is necessary to create everything (at least once!) with the help of the simple text editor, which is exactly what we will do here (see the sidebar, "Taking a Clear Approach").

Before getting started, it's important to note that it is recommended you have some understanding of EJB programming because the goal here is to describe how we apply CMR/CMP techniques in practice, and how that application will work on the BEA WebLogic server. Because we're discussing the simple entity bean, we will not be explaining code, but we'll certainly mention areas that have potential pitfalls while developing your own code. To complete the procedures described here, it's important that your environment be set up as described in the sidebar, "Prepare Your Development Environment."

Start with the Database
Let's begin by creating the MySQL user and database. Assuming that MySQL is installed correctly and you have configured the root user and set its password, you will need to run:

C:\mysql\bin\mysql.exe –u root –p

and enter the password. If you skip configuring the root user (while you were installing your MySQL server), you can simply run:

C:\mysql\bin\mysql.exe

When you see the MySQL client screen, type:

CREATE DATABASE zzzdb;
INSERT INTO mysql.db VALUES (
        'localhost','zzzdb','zzzuser',
        'Y','Y','Y','Y','Y','Y','N','Y',
        'Y','Y','Y','Y');
INSERT INTO mysql.user VALUES (
        'localhost','zzzuser',password(
        'zzzpassword'),'N','N','N','N',
        'N','N','N','N','N','N','N','N',
        'N','N','N','N','N','N','N','N',
        'N','','','','',0,0,0);

You see can see an example in Figure 1. Reload MySQL server by running:

C:\mysql\bin\mysqladmin.exe –u
        root –p reload 

or :

C:\mysql\bin\mysqladmin.exe 
        reload 



Back to top












Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home