WebLogic Installation and Configuration Guide

xiaoxiao2021-03-06  60

Version: 1.2author: dujiang LastModifyData: 2002-07-15

WITH COMPUTER SYSTEM

Dalian

) Inc.

I. BEA WebLogic Introduction:

BEA WebLogic PlatformTM 7.0 is a set of J2EE-based e-commerce suite based on the J2EE function, which provides many e-commerce applications such as JSP and servlets, such as JSP and Servlets, which are easy to program, can provide a complete business application to enterprises. Program.

BEA WebLogic PlatformTM 7.0 passes a unified, simple and scalable build system, allowing companies to improve productivity and reduce costs. BEA WebLogic Platform 7.0 includes the application infrastructure technology unique to the BEA product, including BEA WebLogic ServerTM, BEA WebLogic PortalTM, and BEA WebLogic IntegrationTM. These technologies are combined with BEA WebLogic WorkshopTM to provide a single, unified, and easy-to-use infrastructure platform for application development, deployment, and management. BEA WebLogic Platform 7.0 provides:

The integrated server integrating development, portal and integrated framework, provides a single solution to fully meet the application needs of the enterprise. This platform has reduced product learning, integration, supporting and maintenance workload, which can reduce corporate cost, meet business needs, and give full play to the benefits of an infrastructure asset

Simplify production efficiency by simplifying application development, deployment, and management. Its integrated development framework allows developers (not just J2EE experts) to quickly develop and deploy enterprise-level Web Service applications. Easy deployment and management will reduce maintenance requirements, thereby reducing application maintenance costs, and allows companies to focus on business objectives, rather than technology management.

Scalability open scalability makes the BEA WebLogic Platform 7.0 becomes the best choice and allows companies to give full play to the benefits of existing and future investment. It enables users to freely choose products that best suggest themselves, reduce risks and fully meet the current and future needs of users. BEA WebLogic Platform 7.0 promises full integrated application environment that adapts to both large-scale legacy applications and resolves the need to build and deploy new Java-based Web Services. BEA has created a standard environment that simplifies complex J2EE code and provides powerful management performance.

Second, WebLogic download and installation:

For Java developers, WebLogic can download a complete WebLogic7.0 for free at http://www.bea.com, or fill in a form to request a trial version of the trial version on the BEA's website. We also got a License of WebLogic to License for learning and developing this kit based on this kit. If you need to be officially put into use, then you must pay a certain fee to get the license. Since this kit is based on this release method, we can easily get WebLogic for learning development. Of course, it is necessary to pay.

After downloading, the WebLogic700_win.exe size is about 87m, and the installation will be automatically decompressed after startup.

WebLogic7.0 installation process:

1. Install the startup screen, indicating that the installation is being installed.

2. Select the type of language installed, here only "English" option is available.

3, welcome screen, click "Next" to enter the next step.

4, the bea listens screen, click on Yes, agree to the agreement, and next step.

5, choose the directory you want to install or create a new installation directory

6, select the installation method: Tyical Installation, if you choose to install customization, you will prompt the components you need to install, including server components and some sample source code and project files thereof: 7, ask users The Directory installed by the WebLogic program file is selected.

8, WebLogic7 installation progress

9. Notify the user to install, the directory is E: / BEA / WebLogic700, click "DONE" to end the installation.

10, the installation completed directory structure:

C: / bea> DIR

The volume in the drive C does not have a label.

The serial number of the volume is 1919-1Be5 C: / BEA catalog 2002/07/12 10:46

.

2002/07/12

10:46

..

2002/07/12

10:46

WebLogic700

2002/07/15

10:24

761 UpdateLicense.cmd

2002/07/12

10:47

utils

2002/07/12

10:43

jdk131_02

2002/07/15

10:27

11,242 license.bea

2002/07/15

10:28

712 Registry.xml

2002/07/12

10:49

logs

2002/07/12

10:51

User_Projects

2002/07/15

10:27

5,549 license_new.bea

Second, the configuration in WebLogic 7.0 installation

1. Select "Start" -> "program ->" bea WebLogic Platform 7.0 ", then select" Configuration Wizard "for engineering configuration. 1) Choose Domain Type and name: Select WLS Domain.

2, select the mode of operation of the server,

Choose Server Type: A.Single Server B.Admin Server With Managed Server (s) C.Admin Server With Cluster Managed Server (s) D.Managed Server Description: a. Single Edition (try to use it for learners) B. Similar to 6.1 The default installation of the version is integrated with Managed Server and Admin Server. (For remote control, other Server) c. Cluster Server and Admin Server are integrated together. (Only a large system will be used) D. Simple Managed Server. (Only business, do not manage, local do not save config.xml information) In view of the most friends here, we choose Single Server. Here is a Single mode.

3, the directory stored by the user engineering file, default is "c: / bea / user_projects /", select "Next". I don't know if there is any problem after changing this directory.

4, WebLogic configuration window, where: MyServer is hostname, HTTP service's Dimber thinks 7001, can change, for stand-alone version without writing, default is localhost, if you want to write your own IP.

5. Manage the username and password of the server, then click "Next". The default account is SYSTEM before WebLogic 7, and now the user can customize the management account.

6, INSTALL Sever As Windows Service: NO! (Meaning to add it to the Win2000 system service list, is automatically started by the system, relatively manual control is more flexible)

6. Do you install the program item to the start menu, in order to perform convenience, choose "Yes".

7, configuration information confirmation, select "CREATE" to create this web service.

8, end the configuration. You can also run the wizard again if you want to add additional options.

Description:

Because WebLogic7 comes with JDK1.302, you can do so you can use other JDK versions, and the author will recommend you to use its own JDK to avoid unnecessary trouble.

It should be noted that the system environment variable needs to be added before starting WebLogic7:

Variable name: java_home

Value:% You_Bea_Home% / JDK131_02 This example is E: / bea / jdk131_02

I.e.

In fact, WebLogic6 and 7 have no big differences. The feeling of the author is the directory structure, 7 is more refreshed than 6, which is more convenient for developers.

appendix:

WebLogic6.0 installation and configuration:

1. Install WebLogic to a directory, such as d: /.

2, copy crack.jar to the BEA / WLSERVER6.1 / LIB directory, set the set classpath = in the startWeblogic.cmd file in the BEA / WLSERVER6.0 / Config / MyDomain directory; ./ LIB / WebLogic_sp.jar; ./lib/weblogic.jar (if there is no WebLogic_sp.jar, you need to delete ./lib/weblogic_sp.jar;) change to: set classpath =.; ./ lib / crack.jar;.; ./ LIB / WebLogic_SP. Jar; ./ LIB / WebLogic.jar (if you have other JAR files in your project, you must add your JAR file here.)

3, turn the system environment variable TMP, TEMP to the directory without spaces; in JB6 menu Project - Default Proj

All directorys with spaces are changed to the directory of all belt-free directories in Ect Properties-Paths.

WebLogic default web 埠 7001, we can open a browser input address

Http: // localhost: 7001 / or http: // [hostname]: [port] start

1. Is the test can be connected. WebLogic 6.0 supports JSP by default.

6.0 The three Domain is installed by default. They are Examples, Mydomain and PetStore.

We take myDomain as an example, your JSP file can be put directly

D: /bea/wlserver6.0 / config / mydomain / Applications / DefaultWebApp_myserver directory (individual changes to D: /bea/wlserver6.0 based on the actual situation)

DefaultWebApp_myserver is a Web Application of 6.0 default, we can use it directly.

2. Access your JSP file http://127.0.0.1:7001/xxx.jsp.

3. Make JSP to support Javabean

New Directory ServerClasses in mydomain

Modify StartWebLogic.cmd in the Mydomain directory

At SET ClassPath = .......

You can put it under Mydomain / ServerClasses for JavaBean in JSP.

3. WebLogic6.0 console is an access method implemented in a browser

http://127.0.0.1:7001/console

WEBLOGIC6.0 Creating Pool, DataSource Creation and Use

note

l The following documents are MYDOMAIN as an example.

l This series of documents use the same configuration, that is, the configuration of the previous document,

1. Copy the classes12.zip in the attachment to the WLServer6.0 / lib directory

2. Modify the config / mydomain / startweblogic.cmd file, in set classpath =. . . The final joining the following statement

; ./ LiB / class12.zip

3. Modify the mydomain / config.xml file, add the following statement

CapacityIncrement = "1"

Drivername = "Oracle.jdbc.driver.OracleDriver"

Initialcapacity = "2"

Maxcapacity = "4"

Name = "OracleThinPool"

Properties = "User = Scott; Password = Tiger; DLL = OCIJDBC8; Protocol = Thin"

Targets = "MyServer"

URL = "JDBC: Oracle: Thin: @ 10.2.20.46: 1521: Ambow" / / This is adjusted according to your server address //

/>

JNDINAME = "bbb.oraclethintXDS"

Name = "OTXDS"

PoolName = "OraclethInPool"

Targets = "MyServer"

/>

4. Copy the sss.class in the attachment to mydomain / applications / bbb / web-inf / class

5. Modify the Mydomain / Applications / BBB / Web-INF / Web.xml file,

. . . . . .

. . . . . .

The following statement is added

DataSourceTest

sss

DataSourceTest

/ dst / *

6. Start WebLogic Default Server

7. Access our example http://127.0.0.1:7001/bbb/dst

Use of EJB in WebLogic6.0

WebLoigc installation path, please modify according to the actual situation

1. First need

D: /bea/wlserver6.0/lib/weblogic.jar; d: /bea/utils/utils.jar Setting to ClassPath 2. Compile three source files (see attachment),

MyString.java

MyStringejb.java

MyStringHome.java

For example, the three source files under D: / Ambow,

CD D: / Ambow

Javac my * .java

Generate three files,

MyString.class

MyStringejb.class

MyStringHome.class

3. New directory Meta-INF in the directory of three class files, ie D: / Ambow / Meta-INF

4. Copy the two XML files in the attachment to the newly built meta-inflicity, the meaning of the syntax in the XML file, please refer to WebLogic6.0 related documentation

5. Package file use jar command

Jar cvf myString.jar mystri * .class -c meta-inf / weblogic-ejb-jar.xml meta-inf / ejb-jar.xml

Note that there is a space before

After running this command, generate mYString.jar in the D: / Ambow directory

6. Generate relevant agent classes using WebLogic EJBC commands

In D: / run

Java WebLogic.ejbc Ambow / MyString.jar D: /mystring.jar

This will generate the JAR file we can publish directly in D: / next.

7. DEPLOY

Please use WebLogic Console to Deploy EJB

Deployments-> EJB-> Install a new ejb ...

Don't use the following method to Deploy

D: / java weblogic.deploy -host 127.0.0.1 -port 7001 deploy yourpassword mystring.jar

JAR files treated by EJBC

8. Test EJB Using an Invejb.java (Servlet)

When compiling this file, you need home and remote interface,

That is, mystring.class and mystringHome.class two files, as long as the two files can be in ClassPath. You can put the invejb.java in D: / Ambow, because the two interface files you need are there, or set any one (regardless of whether it has been handled by EJBC) mystring.jar is set to the ClassPath.

Copy Invejb.class to

D: /bea/wlserver6.0/config/mydomain/applications/bbb/web-inf/classes

Modify WeDomain / Applications / BBB / Web-INF Web.xml;

Increase the following statement

invocateejb

invejb

invocateejb

/ invejb / *

9. Copy mystring.class and mystringhome.class to

D: /bea/wlserver6.0/config/mydomain/serverclasses directory

10. After saving related files, start WebLoigic, access the following address

http://127.0.0.1:7001/bbb/INNVEJB

WebLogic uses servlet this article when it is suitable for personal development, there will be special people when the project deploy is

For convenience, please complete the corresponding modification first, then start WebLogic

Some of the following is that it can be done in Console, but because there is some problems with CONSOLE, we directly change the related files directly to config / mydomain as an example.

1. First, create a new Web Application, the method is as follows

Open the config.xml under Mydomain, add the following statement before the final statement

Deployed = "True"

Name = "bbb"

Path = "./ config / mydomain / application"

>

Name = "bbb"

Targets = "MyServer"

URI = "BBB"

/>

save.

2. New Directory BBB in mydomain / applications directory

Built a web-inf directory in the BBB directory

Create a new CLASSES in a web-inflicity

3. Copy the web.xml in the attachment to BBB / Web-INF

Introduction to some statements for web.xml

. . . . . . . . . . . .

. . . . . . . . . . . .

sglzhh

Defining servlet

HHH

hWe

HHH

/ sglzhh / * Note "*" here, the following

4. Copy the hwe.class in the attachment to mydomain / applications / bbb / web-inf / classes directory

5. Start WebLogic6.0 Default Server

6. Visit our small example

Http://127.0.0.1:7001/bbb/boebenben

Note that the BBB here is our newly built web application.

SGLZHH is the name of our servlet

When the mapping is added / *, when you visit, no matter what the file name is added behind http://127.0.0.1:7001/bbb/sglzhh, it shows the content of the servlet.

E.g:

Http://127.0.0.1:7001/bbb/sglzhh

http://127.0.0.1:7001/bbb/sglzhh/kkk.jsp

http://127.0.0.1:7001/bbb/sglzhh/mm.html

The output result is the same

If an individual wants to make a corresponding change according to his hobby, please transfer the example of this document first.

Third, JBuilder6 and WebLogic integrated development environment configuration

1. Open Tools-Enterprise Setup-Application Server, on the weblogic6.x bookmark page, fill in the BEA HOME DIRECTORY (you need to specify when you install WebLogic) and all blank paths such as WebLogC Installation Directory. After this, you open Tools-Configure Libraries, you can see the two WebLogic6.x packages (including deploy and client) on the left, JAR (mainly a WebLogic.jar, a weblogic_sp.jar. Where weblogic_sp.jar is ready to give your weblogic playing, if you don't delete it.) Is a 6.1 version. 2, in the Tools - Enterprise Setup - Application Server panel Select WebLogic 6.x Set WebLogic Installation Directory to d: /bea/wlserver6.1 (so your JSP can also use WebLogic);

BEA Home Directory is set to D: / BEA, then click OK.

Click Default Project Properties to select the Servers panel, select the Servers panel, and click on the Application Server - "....", Double-click the WebLogic Application Server 6.x in the Application Server Select the WEBLOGIC Application Server 6.x Modify VM Parameters as: -ms6

4m -mx64m -djava.library.path = c: /bea/wlserver6.1/bin -dbea.home = c: / bea -dweblogic.domain = mydomain -dweblogic.name = myserver -djava.security.policy == C : /Bea/wlserver6.1/lib/weblogic.policy -classpath.; ./ LIB / WebLogic_sp.jar ;./ LIB / WebLogic.jar ;./lib/ mm.mysql-2.0.14-bin.jar (if Use other JAR files in your project, you must add your JAR file here.) - dWebLogic.Management.password = 123

Click "OK" to determine.

3, in the Tools-Enterprise Setup-Corba tab, click New ... on the right side of Configuration ... Add a "WebLogic" item; add WebLogic directory under Path for ORB Tools; click "under Library for Projects, point" ... "Add to WebLogic6.x Deploy; Fill in Compiler Command Fill in idlj.exe; fill in a directory path in Command Option for Output Directory, but pay attention to it, can't be Chinese, with spaces.

4, Project-Default Project Properties-Servers Point "...". Here to choose Application Server, of course, it is also wleblogic6.x. This is done automatically when JB6 to choose Weblogic6.x deploy and Weblogic6.x client in a Project-Default Project Properties-Path-Required Libraries, Project-Default Project Properties-Build -IDL Weblogic in IDL compiler option. Close the jbuilder. WebLogic configuration is complete. Below is the production of Entity Beans, the database is mysql. Construction table in MySQL:

First create a table used to test, and the database name TEST Table Test We set two fields:

Name vrachar (15) is not allowed to be empty

Addr varchar (50) allows empty

Fourth, WebLogic deployment and management

EJB Development Deployment Process under WebLogic:

1. Create a directory structure according to the specification, write the original file of the bean;

2, compile into CLASS;

3. Use the ANT utility to generate a deployment profile framework for EJB;

4. Pack the program directory into a compression gear with JAR;

5. Copy the compressed file to the Applications directory; start WebLogic in development mode;

6, now you should see you in Console, you should copy the new EJB, but Ant's automatically generated description file cannot fully comply with your requirements, modify it in Console.

7, automatic or manual RedePloy until finally meets your own requirements.

V. Create a MySQL database connection pool in WebLogic

1. Open the Start Default Server in the WebLogic directory in the Start menu, enter the management password, this example is "123", start WebLogic.

2. Start "Start Default Console" and pop up the browser window:

Enter the username "system" password "123" in the password window Enter the console, find the "JDBC" item in the left menu, open him, you will find that there is a "Connection Pools" in the submenu, right click on the item, then Select Configure A New JDBC Connection Pool ... configuration connection pool properties as follows:

Name MySQL Connection Pool

URLJDBC: JDBC: mysql: // localhost / user / user is the database name /

Driver class name org.gjt.mm.mysql.driver In this example, the mysql database can be driver for JDBC for other databases.

Properties (Key = Value):

Port = 3306

User = root

DB = Board

PASSWORD = 123

Server = Fancy Fancy is Host Name

The order of writing can be self-determined, click the CREAT button after completion.

If it is an Oracle database, the first two are like this, the account is set according to your database:

URL: JDBC: WebLogic: Oracle

Driver classes: WebLogic.jdbc.oci.driver

Properties: user = Xixi

Password = Haha Server = Your_tnsname

3. Click the Targets tab, select MyServer, move it into the Chosen item, click Apply. If you are configured wrong, the exclamation mark next to it will flash it to fill in a fault here, you need to change. 4. Select Data Sources in the "JDBC" item, right-click this item, then select "Configure A New JDBC Connection Pool ..." configuration data source.

The property is as follows

Name: MySQL Data Source

JNDI NAME: MySQL

Pool Name: MySQL Connection Pool

The remaining remain default, click "Creat".

5. Click the "Targets" tab, select "MyServer", move it into the "Chosen" item, click "Apply".

6. Turn off the console and WebLogic service. The connection pool and data source are now being built.

Test in JBuider:

1. Open JBuilder, create a newly named Hello project, and add in step 2 in Wizard, Required Libraries

Plus WebLogic 6.1.

2. Create a new EJB Moudle called HelloWorld.

3. Create a new Enterpris JavaBean 1.x, select the HelloWorld group, click Next. Package Select Hello,

Class name is "fistbean", Options Select Container Managed Persistence EJB 1.1 Entit

Y bean then click Next. Click Finish.

4. A total of 3 files under the project is

First.java, FirstHome.java, FirstBean.java

Add to first.java

Public java.lang.string getaddr () throws remoteException;

Public java.lang.string getname () throws remoteexception;

Public void setaddr (java.lang.string addr) throws RemoteException;

Public void setname (java.lang.string name) throws RemoteException;

In fistbean.java

Delete it first:

Public string ejbcreate () throws createException {

/ ** @ Todo: Implement this method * /

Return NULL;

}

Public void ejbpostcreate () throws createexception {

}

Join

Public String Name;

Public String Addr;

Public String Ejbcreate (String Name, String Addr) THROWS CREATEXCEPTION, Remotee

Xception {

SetName (Name);

SetAddr (AddR);

Return NULL;

}

Public string ejbcreate (String name) throws createException, RemoteException {

Return EJBCREATE (Name, NULL);

}

Public void ejbpostcreate (String name, string addr) throws createException, Remot

EEXCEPTION {

}

Public void ejbpostcreate (String name) throws createException, RemoteException {}

Public void setname (String name) {

THIS.NAME = Name;

}

Public void setaddr (string addr) {

THIS.ADDR = Addr;

}

Public string getname () {

Return this.name;

}

Public String getAddr () {

Return this.Addr;

}

In Firsthome.java

Delete:

Public first create () throws remoteException, CreateException;

Join:

Public first create (String name) Throws createException, RemoteException;

Public First Create (String Name, String Addr) Throws CreateException, RemoteExcep

TI;

5. Click HelloWorld in the left menu, then double-click below, click on the resource Re below the right form.

Ferences tab, click the Add button on the panel, enter "First" point OK in the input dialog box, select TYP.

e is java.sql.datasource. Select First, enter hello.firsthome in the JNDI Name box below. Select

The CMP option of the face.

In the WebLogic6.x Properties tag, Mysql is added in the first line (Data-Source-Name)

6. Expand First, double-click CMP1.1, Table (s) Enter "Test", the container management table is as follows

Iscmp ISPK Field TypeColumn Name (s) Column Type

Check Name Namevarchar (15)

Check not addr addrvarchar (50)

7. Right-click on the JDBC1 DataSources under EJB Deployment Descriptor to create a new data source called MySQL,

The configuration is as follows:

JNDI Name MySQL

URLJDBC: JDBC: MySQL: // localhost / test

User name root

Password

Driver class name org.gjt.mm.mysql.driver

Configuration Finish Click "Test Connection", if it is correct

Attempting to connect to Database ...

Connection succeed.

If you display the following information

Attempting to connect to Database ...

Driver NOT On ClassPath.

Add the driver to the classpath using The set classpath command.

Then, the JDBC driver of the database is not in the classpath, add the database driver to the project's Required Libr

Aries.

8. Double-click HelloWorld left, then click EJB DD SOURCE in the window, then select WebLogic-CMP-R

DBMS-JAR.XML Find DataSource to modify to mysql.

9. After saving, press CTRL F9 to compile, there should be no problem.

10. New Test EJB Client all uses the default settings.

11. ReprotteClient1 client = new fistteclient1 (); then add the following code:

First ff = client.create ("testname", "testaddr");

Try {

System.out.println (ff.getname ());

System.out.println (ff.getaddr ());

}

Catch (java.rmi.remoteexception ex) {

EX.PrintStackTrace ();

}

Then, save compilation.

12. Right-click HelloWorld, choose RUN, then select Deploy Options for "HelloWorld.jar"; Deploy

13. After the completion of Start Default Console, the username password is SYSTEM and 12345678 on the left side of the console.

Open the EJB in the menu to select HelloWorld, then select Targets in the right window to turn MyServer into Chosen.

14. Go back to jBuilder to stop the Server in the run, then re-right click HelloWorld, select RUN.

15. Right-click on the fistteclient1.java point run, such as displaying the information below, indicating successful operation

D: /jbuilder6/jdk1.3.1/bin/javaw -classpath "c: / java / jbuilder / hello / jbproject; d: /

BEA / WLSERVER6.1 / lib / weblogic.jar; D: /JBuilder6/lib/jbuilder.jar; D: / jBuilder6 / lib / h

Elp.jar; d: /jbuilder6/lib/gnuregexp.jar; d: /jbuilder6/jdk1.3.1/demo/jfc/java2d/java

2Demo.jar; d: /jbuilder6/jdk1.3.1/jre/lib/i18n.jar; d: /jbuilder6/jdk1.3.1/jre/lib/ja

Ws.jar; d: /jbuilder6/jdk1.3.1/jre/lib/rt.jar; d: /jbuilder6/jdk1.3.1/jre/lib/sunrsas

Ign.jar; d: /jbuilder6/jdk1.3.1/lib/dt.jar; d: /jbuilder6/jdk1.3.1/lib/htmlconverter.

Sixth, JBuilder7 WebLogic7 Access MS SQL Server

1, JBuilder7 WebLogic7 configuration

Suppose JBuilder7 and WebLogic7 are installed, the operating system is: Windows2000 Server (SP2), the database is: SQLServer2000 (SP2).

JBUILDER7 configuration:

1. Modify environment variables TEMP and TMP for directorys without spaces, such as: E: / WinNT / TEMP

2. Start JBuilder7, choose: Tools-> Configure Servers

3. Select the WebLogic Application Server 6.x on the left, select the enable server on the right.

4. Set General-> Home Directory to WebLogic7 Home Directory, such as: E: / BEA / WebLogic700 / Server, and normal JBuilder7 will automatically add other items to you.

5. Set the Custom-> JDK Installation Directory to JDK installation directory, such as: E: / BEA / JDK131_02

6. Set the Custom-> Bea Home Directory to WebLogic7 Home Director, such as: E: / BEA7, set the Custom-> Domain Directory as your domain directory, such as: E: / bea / user_projects / mydomain

8. After adding USER Name, Password, Domain, Server Name, click OK to exit.

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

Name for this configuration = Wellogic 7.0

Path for orb Tools = E: / bea / WebLogic700 / Server

Library for processing = WebLogic 6.x Deploy

IDL Compiler Command = idlj.exe

Commnad option for output directory = E: / corbaoutput (any directory, do not have spaces)

Click OK to exit.

10. Choose Project-> Default Project Properties

WEBLOGIC 6.X Client and WebLogic 6.x deploy in the Required Libraries in the PATH page are not, please check if the above steps are correct.

11. Select Server page, click Single Services for All Service in Project

Select WebLogic Application Server 6.x in the drop-down list, but strike OK exit, configure it.

WebLogic7 configuration:

1. Start WebLogic7

2. Open IE6, type in the address bar: http: // localhost: 7001 / console

3. Enter your username and password

4. Select Services-> JDBC-> Connection Pools in the directory tree on the left, click the Configure a new JDBC Connection Pool on the right. You enter the following information:

Configuration-> General Page:

Name = SQL Server Connection Pool

URL = JDBC: WebLogic: MSSQLSERVER4: Northwind @ localhost

Driver classname = WebLogic.jdbc.msqlserVer4.driver

Properties: User = SA

Password = "" <- SA password

Click Create to establish a connection pool.

Targets-> Server Page:

Move your MyServer to the list of the right, but click Apply

5. Select Services-> JDBC-> Data Sources-> JDBC-> Data Sources-> JDBC-> Data Source, click on the CONFIGURE A NEW JDBC Connection Pool on the right. Enter the following information:

Configuration-> General Page:

Name = SQLSERVER TX DATA SOURCE

JNDI Name = SQLSERVERPOOL Name = SQL Server Connection Pool

Select Emulate TWO-PHASE COMMIT for Non-Xa Driver and Row Prefetch Enabled

Click Create to establish a data source.

Targets-> Server Page:

Move myServer to the list of the right, but click Apply, the configuration is complete.

Practical 1: Connect SQLServer2000

1. Open JBuilder7 Select File-> New Project

Enter SQLSERVERDEMO in the Name column, enter the storage path in the Directory column (do not have spaces), other unchanged, click Finish.

2. Select File-> New, select General-> Application, click OK.

The first step, the second step and third steps do not have to be changed, directly finish.

3. Go back to the JBuilder7 integrated development environment, click the Designer page design form on the right, put a JScrollPane and Jtextarea and three buttons in the form, double-click the first button to enter the following code:

Try

{

Class.Forname ("WebLogic.jdbc.mssqlserVer4.driver");

Connection con = DriverManager.getConnection ("JDBC: WebLogic: MSSQLServer4: Northwind @ localhost", "sa", ""); // is based on your SQLServer account.

Statement ST = con.createstatement ();

ResultSet Res = St.executeQuery ("Select * from Employees);

String line = "";

While (res.next ())

LINE = line res. maxString ("Title") "/ n";

Jtextarea1.settext (line);

C. close ();

}

Catch (Exception EX)

{

Jtextarea1.settext ("Error:" ex.getMessage ());

}

Double-click the second button to enter the following code

Hashtable ht = new hashtable ();

HT.PUT (Context.Initial_Context_Factory, "WebLogic.jndi.wlinitialContextFactory";

HT.PUT (Context.Provider_URL, "T3: // localhost: 7001");

Try

{

Context CTX = New InitialContext (HT);

DataSource DS = (Datasource) CTX.lookup ("SQLServer");

Connection Con = DS.GetConnection ("System", "12345678"); // This is the domain and password of WebLogic7

Statement ST = con.createstatement ();

ResultSet Res = St.executeQuery ("SELECT * from Employees"); String line = "";

While (res.next ())

LINE = line res. maxString ("notes") "/ n";

Jtextarea1.settext (line);

C. close ();

}

Catch (Exception EX)

{

Jtextarea1.settext ("Error:" ex.getMessage ());

}

Run WebLogic7, run the program Click the first button to connect SQL Server directly using JDBC and get data, click the second button to connect SQL Server with DataSource and get data.

V. Development and packaging process of EJB project:

1. Open JBuilder6, create a new Hello project, and add WebLogic 6.1 in Required Libraries in step 2 of Wizard.

2. Newly built an EJB Moudle named HelloWorld.

3, new Enterpris Javabean 1.x, select the HelloWorld group, click Next. Package Select Hello, class name to "fistbean", Options Select Container Managed Persistence EJB 1.1 Entity Bean and click Next. Click Finish.

4. A total of 3 files under the project is:

First.java, FirstHome.java, FirstBean.java

Add: in First.java:

Public java.lang.string getaddr () throws remoteException;

Public java.lang.string getname () throws remoteexception;

Public void setaddr (java.lang.string addr) throws RemoteException;

Public void setname (java.lang.string name) throws RemoteException;

In fistbean.java

Delete it first:

Public string ejbcreate () throws createException {

/ ** @ Todo: Implement this method * /

Return NULL;

}

Public void ejbpostcreate () throws createexception {

}

Join

Public String Name;

Public String Addr;

Public String Ejbcreate (String Name, String Addr) THROWS CREATEXCEPTION, Remotee

Xception {

SetName (Name);

SetAddr (AddR);

Return NULL;

}

Public string ejbcreate (String name) throws createException, RemoteException {

Return EJBCREATE (Name, NULL);

}

Public void ejbpostcreate (String name, string addr) throws createException, Remot

EEXCEPTION {

}

Public void ejbpostcreate (String name) throws createException, RemoteException {}

Public void setname (String name) {

THIS.NAME = Name;

}

Public void setaddr (string addr) {

THIS.ADDR = Addr;

}

Public string getname () {

Return this.name;

}

Public String getAddr () {

Return this.Addr;

}

In Firsthome.java

Delete:

Public first create () throws remoteException, CreateException;

Join:

Public first create (String name) Throws createException, RemoteException;

Public First Create (String Name, String Addr) Throws CreateException, RemoteExcep

TI;

5, click HelloWorld in the left menu, then double-click below, click the Resource References volume list under the right form, click the Add button on the panel, enter "first" point OK in the input dialog box, select Type Java.sql.datasource. Select First, enter hello.firsthome in the JNDI Name box below. Select the following CMP option.

In the WebLogic6.x Properties tab, mysql6 is added to the Data-Source-name. Expand First, double-click CMP1.1, Table (s) Enter "Test", the container management table is as follows:

Iscmp ISPK Field TypeColumn Name (s) Column Type

Check Name Namevarchar (15)

Check not addr addrvarchar (50)

7. Right-click on the JDBC1 DataSources under EJB Deployment Descriptor to create a new data source called MySQL, configured as follows:

JNDI Name MySQL

URLJDBC: JDBC: MySQL: // localhost / test

User name root

Password 123

Driver class name org.gjt.mm.mysql.driver

Configuration Finish Click "Test Connection", if it is correct

Attempting to connect to Database ...

Connection succeed.

If you display the following information

Attempting to connect to Database ...

Driver NOT On ClassPath.

Add the driver to the classpath using The set classpath command.

Then indicate that the JDBC driver of the database is not in the classpath, adds the database's driver to the project's Required Libraries.

8, double-click the HelloWorld left, then click EJB DD SOURCE in the right window, then select WebLogic-Cmp-Rdbms-Jar.xml to find DataSource to modify to mysql.

9. After saving, press CTRL F9 to compile, there should be no problem.

10. New Test EJB Client all uses the default settings.

11, then find fistteclient1 client = new fistteclient1 (); then add the following code:

First ff = client.create ("testname", "testaddr");

Try {

System.out.println (ff.getname ());

System.out.println (ff.getaddr ());

}

Catch (java.rmi.remoteexception ex) {

EX.PrintStackTrace ();

}

Then, save compilation.

12. Right-click HelloWorld, choose RUN, then select Deploy Options for "HelloWorld.jar"; Deploy

13. After the completion of Start Default Console, the username password is System and 12345678 on the left side of the console.

Open the EJB in the menu to select HelloWorld, then select Targets in the right window to turn MyServer into Chosen.

14. Go back to jBuilder to stop the Server in the run, then re-right click HelloWorld, select RUN.

15. Right-click on the fistteclient1.java point run, if the information below shows the successful operation

D: /jbuilder6/jdk1.3.1/bin/javaw -classpath "c: / java / jbuilder / hello / jbproject; d: /

BEA / WLSERVER6.1 / lib / weblogic.jar; D: /JBuilder6/lib/jbuilder.jar; D: / jBuilder6 / lib / h

Elp.jar; d: /jbuilder6/lib/gnuregexp.jar; d: /jbuilder6/jdk1.3.1/demo/jfc/java2d/java

2Demo.jar; d: /jbuilder6/jdk1.3.1/jre/lib/i18n.jar; d: /jbuilder6/jdk1.3.1/jre/lib/ja

Ws.jar; d: /jbuilder6/jdk1.3.1/jre/lib/rt.jar; d: /jbuilder6/jdk1.3.1/jre/lib/sunrsas

Ign.jar; d: /jbuilder6/jdk1.3.1/lib/dt.jar; d: /jbuilder6/jdk1.3.1/lib/htmlconverter.

JAR; D: /JBUILDER6/JDK1.3.1/lib/tools.jar "Hello.firsttestClient1

Initializing Bean Access.

- succeeded initializing bean access.

- Execution Time: 2454 ms.

- Calling Create (Testname, TestAddr)

- succeeded: Create (Testname, TestAddr)

- Execution Time: 90 ms.

- Return Value from Create (Testname, Testaddr): WebLogic.rmi.Cluster.EntityRemo

TEREF @ 10e - jvmid: '-6793290705 ...

Testname

TestAddr

Note: This program can only run once. Run again, you need to change the first line of step 11.

转载请注明原文地址:https://www.9cbs.com/read-118788.html

New Post(0)