Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure EJB for JBuilder7+Weblogic7+mysql developer

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the JBuilder7+Weblogic7+mysql development EJB how to configure, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Configuring JB+WLS can be said to be a nightmare. I searched all the posts that can be found on the Internet, but there are only three or four of them.

The post is really good in some aspects, and it is with the help of them that the author has successfully integrated JB7+WLS7 after several days of hard groping.

And MYSQL database to develop EJB. But these posts are all former JB4-6 WLS 5-6. In the case of 1, there are many options that are not applicable

In JB7+WLS7, which is unilateral, there is no complete documentation from configuration to deployment.

First, forget about the installation.

Configuration: after installing JB7 and WLS7, you should configure WLS7 first, because WLS7 configuration has nothing to do with JB7 and JB7 has to choose the environment of WLS

Here is a step-by-step explanation in order:

The example field I used in the document (that is, using "such as: field"), then when I want to use this field, I will write it directly as the following field.

Configure MYSQL (all other databases are the same) create a new library name, such as ejbdb, and configure the user name and password such as (root,111111)

Put the jdbc of mysql (such as mysql.jar) in a directory, usually under% JAVA_HOME%/lib/. But as long as it's not on the floppy disk,

You can always find it.

Configure WLS7

If WLS7 is installed under c:ea, go to the c:eaweblogic700in directory and modify startWLS.cmd (note that you modify this first

The file is because some documents say that it is wrong to modify the startWeblogic.cmd under c:eauser_projectsmydomain. ) repair first

Change this file when the startWeblogic.cmd under c:eauser_projectsmydomain has not yet been generated, make sure you will not correct your mistakes. Such as

If the startWLS.sh is modified under linux

Find set CLASSPATH=%JAVA_HOME%lib ools.jar;%WL_HOME%serverlibweblogic_sp.jar.

% WL_HOME%serverlibweblogic.jar;%CLASSPATH%

Add mysql.jar: Cheng

Set CLASSPATH=%JAVA_HOME%lib ools.jar;%WL_HOME%serverlibweblogic_sp.jar

% WL_HOME%serverlibweblogic.jar;pathmysql.jar;%CLASSPATH%

Archive exit and run BEA Weblogic platform 7. 0-> domain configuration wizard on the startup menu.

Configuration wizard .

1.Select a template: select WLS Domain,Name default mydomain

2.Choose Server Type: the first one

3.Specify directory for "mydomain" domain:C:eauser_projects

4.value Administrative Server Info-Admin Server Name or IP writes the ip of the machine, so it is safe, and other defaults

5.Configure Managed Server: Server Name: default is myserver

Server Listen Address: write the machine's ip. Other default

6.Create System UserName and Password: write user name and password, such as system:aaaaaa

7.Install Server as Windows Servic: ask here whether you want to boot when you boot the operating system, and you can choose according to your needs.

8.Install Domain in Windows Start Menu: ask here if you want to add a shortcut to the start menu. The suggestion is "Yes".

So EBA Weblogic Platform 7.0-> User projects-my domain- > Start Server appears in the start menu

If yes is selected for 8, start now-> EBA Weblogic Platform 7.0-> User projects-my domain- > Start Server

Wait a minute, enter after startup: http://localhost:7001/console if you can't find the page, change localhost to hostname or IP.

If you can't go to the steps above, anyway, if you can't access it here, you'll have to visit this page for me anyway.

Enter the username and password (system:aaaaaa) you just entered.

Select Services- > JDBC- > Connection Pools in the directory tree on the left, and click Configure a new JDBC Connection Pool on the right.

Enter the following information:

Configuration- > General page:

Name = Mysql Connection Pool

URL = jdbc:mysql://localhost:3306/ejbdb (note that ejbdb is my example field above, as will be the case below)

Driver classname = org.gjt.mm.mysql.Driver

Properties:

User=root

Password=111111, these two lines are the contents of Properties, that is, name=value form.

Click Create to establish the connection pool.

Select the Targets- > Server page:

Move myserver (server name) to the list on the right, but click Apply

Select Services- > JDBC- > Data Sources (or TXData Sources) in the directory tree on the left and click Configure a new JDBC on the right

Connection Pool., enters the following information:

Configuration- > General page:

Name = Mysql Tx Data Source

The name JNDI Name = ejbPool is the DataSource name that you will quote later.

Pool Name = Mysql Connection Pool

Check Emulate Two-Phase Commit for non-XA Driver and Row Prefetch Enabled

Click Create to establish the data source.

Targets- > Server page:

Move the myserver (server name) to the list on the right, but click Apply to complete the configuration

-

Configure JB7

1. Change the environment variables TEMP and TMP to directories without spaces such as c:winnt emp. Be careful, or the release will not be successful.

two。 Start Jbuilder7,Tools- > Configure libraries- > class- > Add and find mysql.jar,OK,OK

3. Select: Tools- > Configure Servers check Weblogic Application Server 6.x on the left and select the one on the right

Enable Server

4. Set General- > Home Directory to the Home Directory of WebLogic7, such as c:/bea/weblogic700/server, normal

Then Jbuilder7 will automatically add other items for you. Server parameters is not entered. Use add plus mysql.jar in the following class by default

Add c:/bea/weblogin700/server/lib/weblogic.jar and c:/bea/weblogin700/server/lib/weblogic_sp.jar, if

There is no indication that the c:/bea/weblogic700/server is not specified correctly. Actually, c:/bea/weblogin700/server/lib/weblogic_sp.jar is not saved.

Yes, don't worry about it. Just add mysql.jar in. If 2 is not done, it will not be found.

5. Set Custom- > JDK Installation Directory to the directory where JDK is installed, such as c:/bea/jdk131_02

6. Set Custom- > BEA Home Directory to the Home Director of WebLogic7, such as c:/bea

7. Set Custom- > Domain Directory to your domain directory, such as c:/bea/user_projects/mydomain

8. After adding User name, Password, Domain name and Server name, click OK to exit.

9. Select: Tools- > Enterprise Setup, click New on the CORBA page, and fill in the appropriate information according to the following table:

Name for this configuration = WelLogic

Path for ORB Tools = c:/bea/weblogic700/server

Library for Projects = WebLogic 6.x + Deploy

IDL compiler command = idlj.exe

Commnad option for output directory = c: emp (any directory, no spaces)

Click OK to exit.

It's best to keep using jb7's own JDK1 in 10.config JDKS. three. 1 or use the JDK under EAB, do not change to another installation of JDK1. 4, because

There are some native method implementations in this version that don't work well with WLS and are bound to go wrong.

11. Select Project- > Default Project properties and you will see WebLogic 6.x + in the Required libraries of the Path page.

Client and WebLogic 6.x + Deploy. If not, please check whether the above steps are correct. Select the Server page and click Single services

For all service in project, select WebLogic Application Server 6.x quit from the drop-down list, but click OK to exit.

twelve. Tools- > Database pilot- > view- > options- > Drivers- > Add, enter org.gjt.mm.mysql.Driver in the pop-up dialog box

After confirming, enter mysql://localhost:3306/ejbDB in the Simple URL below, and notice that there is no "jdbc:" confirmation.

Pop up new URL in File- > New, and select Driver as the org.gjt.mm.mysql.Driver you just added, and the URL will automatically be displayed as

Jdbc:mysql://localhost:3306/ejbDB, OK, and then click the arrow down to the right in the toolbar (apply). Double-click the one you just added on the left

Enter the user name root and password 111111 to test whether the database link is passed. If you do not see the table below, please check the above steps.

-

Develop EJB

File- > New Project generate a new project; for example: myproject

File- > New Select Enterprise and select EJB2.0 Bean Designer,OK.

Press New to pop up EJB module Wizard,Name and change it to AccountApp, and the designer AccountApp appears on the left group tree. Click the plus sign in front of it.

See JDBC 1 Datasources and Security Roles under it. Double-click the EJB designer AccountApp, and the design interface is displayed on the right, and later from another interface

To return to the design interface, double-click the designer. Click the first icon on the sidebar, and there is a sun on something like a millet. Title is

Create EJB. There are four options, CMP2.0,BMP,SESSION,MESSAGEp four kinds of BEAN, this example choose BMP, come out the Bean design window, there will be one on the right

Bean properties box, but if you MOUSE it fast, it may disappear. Never mind, left-click on BEAN's name will come out and change BEAN's name to

AccountBean,interface is local/remote. Alway warp primary key is true, click classes and package:

Package: change the name of the package you want to put. This example is: com.fuck.axamn

It's fine if you use the default class name, but I like to add Remote in the remote interface and local in the local interface, and JB is just the opposite.

Bean class: com.fuck.axamn.AccountBean

Home interface class: com.fuck.axamn.AccountRemoteHome

Local Home interface class: com.fuck.axamn.AccountHome

Remote interface calss: com.fuck.axamn.AccountRemote

Local interface calss: com.fuck.axamn.Account

In this case, I named it like this:

Bean class: com.fuck.axamn.AccountBean

Home interface class: com.fuck.axamn.AccountHome

Local Home interface class: com.fuck.axamn.AccountLocalHome

Remote interface calss: com.fuck.axamn.Account

Local interface calss: com.fuck.axamn.AccountLocal

Right-click the name of BEAN on the Bean design window and select view source. OK, type the example by hand. Don't COPY up yet, you can deepen your understanding by tapping it yourself. Such as

If there is a mistake in the end, then COPY.

After the Bean class itself is designed, click on the package above the designer on the left to see its interface class. One click on the right will show the source code, one by one.

Designed to add a satellite class (such as AccountExeption in this example), right-click package, select Add files/packages, and add a java file

Be careful to be in the same directory as the automatically generated files.

After all is written, right-click the project name, make, and then press F9 to run. If WLS doesn't start, JB will start it automatically.

When there is no problem, right-click on the designer and select Deploy to publish to WLS smoothly. After entering from http://localhost:7001/console, you can see AccountApp.

Has been posted to WLS.

-

Test:

In engineering, File- > New- > Enterprise- > EJB test Client. Name is set to AccountClient

Double-click AccountClient.java in the left component tree to edit what is provided in this example.

Mysql-uroot-p

111111

Use ejbdb

Create table accounts (id varchar (60) not null primary key,ownerName varchar (60), double balance (8) default 0.00)

Make AccountClient.java

Run AccountClient.java

_

Developing CMP with JB7+WLS7+MYSQL

CMP development is actually simpler than BMP (I'm talking about operational simplicity), as long as your business logic is defined.

In fact, it is very fast when it is realized. But I can't find any example of developing CMP with JB on the Internet. There is an article on J Road.

It's too dark to charge 50 yuan to teach people how to develop CMP with JB. And it has long hair, so I don't dare to be there.

Publish this article, but please post it to each other somewhere else, don't let that guy cheat other people's money.

It is actually very convenient for JB to develop CMP, but most people do not know how to operate it, because CMP is not derived from the BEAN designer.

The design interface is established. And many options are not explained by others and really do not know what to choose.

The previous topic is that JB7+WLS+MYSQL has been configured according to the original configuration article.

From now on, let's first define the database of CMP persistence fields. For example, we are going to do a BEAN for Product, which includes four

Fields:

ProductID: product number (unique)

Name: product name

Description: product description

BasePrice: base price of the product

Then first define the database:

Mysql-uroot-p

111111

Use ejbdb

Create table ProductBean (

ProductID varchar (60) not null primary key

Name varchar (60)

Description varchar (200)

BasePrice double (8 dint 2) default 0.00

);

Start JB7.

File- > New Project- > enter the project name such as: myproject2

File- > New Select Enterprise and select EJB2.0 Bean Designer,OK.

Press New to pop up EJB module Wizard,Name to ProductApp, and designer ProductApp appears on the left group tree

Be careful not to Create EJB from the design interface on the right, double-click the designer ProductApp, and it will appear under the component tree

DataSources, right-select Import Schema From Database, pop-up Database Schema provider window

Tick before All schema.

Select Driver as org.gjt.mm.mysql.Driver, and the following url will automatically set the URL for you. Pay attention to the

Originally, you shouldn't add jdbc:, when setting URL, or there will be jdbc:jdbc:mysql://localhost:3306/ejbdb here.

If you remove a "jdbc:" like this, enter username and password (root:111111). Set the default in jdni name

The value DataSource changes to the JDIN NAME when you configure MYSQL in WLS (in this case, ejbPool). Click OK, if the link

An ejbPool will appear under the DataSources successfully. Click the + sign in front of it to see the places under the ejbdb library.

There is a table, and we are now going to use the productbean table as the correspondence of the persistent field, so right-click productbean

Choose the first item Create CMP2.0 Entity Bean. Notice that Mysql sets the table names to all lowercase, so the new Bean

Is named Productbean, and a Bean design window named Productbean is generated in the design interface on the right, left-click

Name, the properties dialog box appears on the right:

Bean name: changed to ProductBean.

Abstract Schema name: will automatically change to ProductBean.

Interface:local/remote

Always wrap primary key:true

Classes and packages: same as BMP, the default name is:

Bean class: com.fuck.axamn.ProductBean

Home interface class: com.fuck.axamn.ProductRemoteHome

Local Home interface class: com.fuck.axamn.ProductHome

Remote interface calss: com.fuck.axamn.ProductRemote

Local interface calss: com.fuck.axamn.Product

In this case, I named it like this:

Bean class: com.fuck.axamn.ProductBean

Home interface class: com.fuck.axamn.ProductHome

Local Home interface class: com.fuck.axamn.ProductLocalHome

Remote interface calss: com.fuck.axamn.Product

Local interface calss: com.fuck.axamn.ProductLocal

In CMP properties, this example is a BEAN corresponding to a table, so the first Single table maping

If it is a BEAN associated with multiple tables, select the second item, and then put the primary key on the left and the corresponding fields of each table on the right

Just connect it with a red line. If you just click on the fields of primary key, there will be a red line.

Click package above the designer ProductApp on the component tree on the left, click on it level by level, and see the 5 files generated.

ProductHome.java

ProductLocalHome.java

Product.java

ProductLocal.java

ProductBean.java

Type in one by one according to the contents of the document in the attachment to this example. When you are finished, double-click the designer to return to the BEAN design interface on the right, and you will see

There are seven finder methods to ProductBean. FindByPrimaryKey is automatically generated by the system, which you don't need to consider.

But it is impossible for the other 6 systems to know what conditions you are looking for, so write EJB-QL manually.

Click on each method and the dialog box will pop up on the right, and nothing else will be moved. Type in the bottom Query content box to

The corresponding content under

FindByName method: SELECT OBJECT (p) FROM ProductBean AS p WHERE p.name=?1

FindByDescription method: SELECT OBJECT (p) FROM ProductBean AS p WHERE p.description=?1

FindByBasePrice method: SELECT OBJECT (p) FROM ProductBean AS p WHERE p.basePrice=?1

FindExpensiveProducts:SELECT OBJECT (p) FROM ProductBean AS p WHERE p.basePrice

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report