JBuilder + WebLogic implements the teaching material management system

Source: Internet
Author: User

  AbstractThis article studies how to use the original heterogeneous database to establish a Department Management System in the campus network environment, and introduces the design and implementation process of the comprehensive management system for teaching materials based on WebLogic application server.

  KeywordsDatabase; J2EE; EJB; WebLogic
  Introduction

With the continuous improvement of science and technology, the function of computer networks has been deeply recognized. It has entered various fields of human society and played an increasingly important role. The campus networks of various schools have also been running for many years. However, many school management systems lack unified planning, and there are still many isolated standalone information islands, therefore, it is necessary to study how to use the original heterogeneous database to establish a management system for relevant departments in the campus network environment.

An independent database management system has been provided for teaching and teaching material warehouses in a university. However, the selection and ordering of teaching materials are performed manually, resulting in low labor cost and efficiency. The necessity of using existing resources to establish a comprehensive management system for teaching materials on campus network is self-evident! This article introduces the design and implementation of a comprehensive textbook Management System Based on WebLogic application server.

  System Structure

The system includes the teaching material selection, query, modification, and ordering subsystems. The educational administration information and teaching material inventory information required by the system are from the original online database, as shown in figure 1. The Teaching and Research Section can select, query, and modify teaching materials through the B/S mode. The teaching material management is completed locally by the teaching and research board in the C/S mode, it mainly refers to Teaching Material Ordering and system management.

Design and Implementation of the comprehensive teaching material management system

1. Database Design

The database system includes the Academic Affairs Office database (old), warehouse database (old), and textbook committee database (new), which fully utilizes the original resources to share data, the tables used include the course schedule table of the Academic Affairs Office, the number of professionals table, and the inventory table of the warehouse.

Number of students in the Academic Affairs Office:

Column name Data Type Length Allowed to be empty
ID Bigint 8 No
Num Int 4 Yes

Course schedule of Academic Affairs Office:

Column name Data Type Length Allowed to be empty
ID Bigint 8 No
CID Int 4 No
Cname Varchar 50 Yes
Teachunit Varchar 50 Yes
Sname Varchar 50 Yes

Warehouse inventory table:

Column name Data Type Length Allowed to be empty
Bid Int 4 No
Bname Varchar 50 Yes
Bnote Varchar 50 Yes
Bauthor Varchar 50 Yes
Bpublisher Varchar 50 Yes
Bprice Float 8 Yes
Bnum Int 4 Yes

The Textbook Board manages the selection and ordering of textbooks in a unified manner. It has a local database, that is, the textbook board database. There are three tables in this new database, one is used to store the data after the teaching material is selected, the other is used to store the order content, and the third is the information storage of the login password of the Teaching and Research Section.

Select Teaching Material Table:

Column name Data Type Length Allowed to be empty
CID Int 4 No
Bid Int 4 Yes
Cname Varchar 50 Yes
Bname Varchar 50 Yes
Teachunit Varchar 50 Yes

Order table:

Column name Data Type Length Allowed to be empty
ID Bigint 8 No
Bname Varchar 50 Yes
Numneed Int 4 Yes

Password table:

Column name Data Type Length Allowed to be empty
Teachunit Varchar 50 No
PW Char 10 Yes

They are all the underlying structures in J2EE. the WebLogic application server layer needs to configure the data pool and data source to connect the underlying database.

2. Data Pool and data source configuration

Because there are three databases in the database system, you need to configure three connection pools when configuring the Weblogic connection pool. Here you enter the Weblogic console page to configure the first connection pool and the educational database connection pool (2) for example. The most important thing is to use the driver of the corresponding database category in the URL and driver, and fill in the name of the database to be accessed, the address and port of the database server.


Figure 2 connection pool Configuration

The repository database URL is: "JDBC: oracle: CK: @ localhost: 1521"
Driver: "Oracle. JDBC. Drive. oracledriver"

The textbook committee URL is: "JDBC: WebLogic: mssqlserver4: Teachingmanagement@10.10.11.81: 1057"
Driver: "weblogic. JDBC. mssqlserver4.driver"

Configure the data source and define the JNDI name of the data source based on the data pool name. In this way, the three databases distributed in different regions are connected in WebLogic, and the categories, versions, and regions of the database software are shielded. The data source configuration of the Academic Affairs Office is 3:


Figure 3 data source configuration

3. Create an object EJB

The system needs to operate on six tables in three remote databases. Therefore, we need to introduce and create corresponding entity beans one by one, here we will introduce all the tables used by the system in the three databases to the same EJB module.

The Entity Bean generated in JBuilder automatically identifies and generates the corresponding table name, data segment name, and attributes, according to the local or remote home interface file set by the programmer, it encapsulates the basic actions for database operations, such as using the primary key query record function to obtain and set the function of the data item in the searched record. In order to add some functions for the later subsystem's needs:

In the course schedule table Entity Bean, add two finder:

The name of a finder is findall. The function is to obtain all the information in the course schedule table of the educational administration database. It will be used when all course information is written to the selected textbook table.

The other name is findbycid. The function is to find the major that has selected these courses based on the entered course information.

Add two finder in the selected textbook table:

A table named findall is used to obtain information about all the selected teaching materials.

The other name is findbybid, which is used to obtain the corresponding major.

Add a finder in baobiao as findall to obtain information in all order tables.

This completes the establishment of the system Entity Bean.

4. Create a session EJB

Session beans can be used to model the processing or control objects of a customer, model workflows, tasks, and management activities, and coordinate multiple entity beans, controls the interaction between entity beans and transfers the business application logic from the client to the server. This system considers that the data is not very huge. Only one stateless session EJB (connectejbs) with a remote interface is used to complete all tasks related to the entity EJB.

6 private variables and 6 public variables are added to the system for the purpose of functions. After initialization, they are used to access the entity ejbs corresponding to the six tables. The initialization code is:

Try {
Context context = new initialcontext ();
Object ref = context. Lookup ("Java:/COMP/ENV/coursearrangement ");
Crthome = (coursearrangementhome) ref;
Ref = context. Lookup ("Java:/COMP/ENV/XK ");
Xkhome = (xkhome) ref;
Ref = context. Lookup ("Java:/COMP/ENV/TP ");
Tphome = (tphome) ref;
Ref = context. Lookup ("Java:/COMP/ENV/number ");
Numberhome = (numberhome) ref;
Ref = context. Lookup ("Java:/COMP/ENV/ck ");
Ckhome = (ckhome) ref;
Ref = context. Lookup ("Java:/COMP/ENV/baobiao ");
Baobiaohome = (baobiaohome) ref;
} Catch (exception e) {e. printstacktrace ();}

In this way, you can access the automatically generated and added methods or functions in the Entity EJB through the remote interface of the session EJB, provided that this method or function is included in the home interface of the entity EJB.

Some local public functions and Multiple Remote public functions are added to modify or access the entity EJB for preliminary processing. The added function must first right-click the graph add method that represents the session bean in JBuilder. After setting parameters, right-click the Session Bean and select the view bean sourse menu, go to the code area to edit the method subject. Otherwise, the project will produce a compilation error. Here we provide the functions required by the entire system to deal with databases. These interfaces are useful in the following article.

Three local public functions: functions independent of multiple write operations in the same function

① Public void writecidcname (integer CID, string cname, string teachunit)

This is to write course information to the selected teaching material table.

② Public void writebook (integer bid, string bname)

In this case, the teaching material information is written into the Order table.
 
③ Public void writealltp (string unit, string PW)

Similarly, to write password information to the password table.

Remote public functions: the following functions are required by the order subsystem.

(1) Public java. util. Collection couinfo ()

This function is used to obtain information about courses offered from the academic affairs office. The returned value is a collection object.

(2) Public Boolean writexk (Java. util. Collection RST)

This function is automatically called when the order subsystem is running. It is responsible for writing the course information obtained from the academic affairs office into the Selected Teaching Materials table during system initialization, so as to ensure that new teaching and research sections can be obtained in real time. Its parameter is the return value of the function zhuanyi (), and the local function ① is called in the program body.

(3) Public java. util. Collection selectunit ()

This function is used to obtain the names of all teaching and research sections of the course from the selected teaching materials table. It is required to get the Teaching and Research Section name drop-down box on the B/S login interface and to get the Teaching and Research Section name in the password table. Note that duplicate information exists here, and you need to call its function to filter it out.

(4) Public Boolean writetp (Collection rst, string PW)

This is written to create the password table of the Teaching and Research Section. It is called after function 2. When there is no Teaching and Research Section in the table or a New Teaching and Research Section, it is automatically added to the password table and the original password is allocated. It is a sub-system that allows instructors to log on and reproduce teaching materials.

Required Public Boolean reflushbaobiao ()

This is the C/S interface. When you refresh the order information, you can write the selected textbook information in the selected textbook table into the Order table. It is called before obtaining the appropriate quantity of teaching materials.

● This is a function written to obtain the number of books to be subscribed to in an order. Because you cannot operate multiple databases in one function, the following functions are used to implement this function.

Obtain all teaching material numbers in the order table:

Public Collection readbaobiaoforgetnum ()

 
Obtain the course number corresponding to the selected textbook from the selected textbook table:

Public integer readxkforgetnum (integer bid)

 
Then, we can find from the course schedule table that the course number represents more than one major:

Public Collection readcouforgetnum (integer CID)

Then, the number of students of these majors can be found in the Academic Affairs table:

Public integer readnumforgetnum (long ID)

Find out the inventory of this book in the warehouse. If the required quantity is greater than the inventory, you must display the order quantity in the order:

Public integer readckforgetnum (integer bid, int numall)

○ The following functions are used for instructor online Textbook Selection and related unit query.

(1) Public String login (string Unit)

This is used when the user logs on to the system to check whether the Password Matches, that is, the corresponding password is queried based on the user name and returned. When the user changes the password, verify whether it is used by the login user.

(2) Public String login (string Unit)

This function is used by the system to check whether the Password Matches when the user logs on to the system. The corresponding password is queried based on the user name and returned. When the user changes the password, verify whether it is used by the login user.

(3) Public Boolean writein (integer CID, integer bid, string name)

This function writes the course information to the corresponding database record.

(4) Public Boolean setpw (string unit, string PW)

This function is used when the user changes the password.

Required Public Boolean isbooksame (integer bid)

This function is used to determine whether the user enters the teaching material information repeatedly or when the user enters the Selected Teaching Material of another course, to prevent repeated insertion of the database primary key.

Using public object getbidname (integer CID)

This is an interface for the Teaching and Research Section to query the preparation of selected teaching materials and provide reference for the selection of teaching materials.

5. Order Subsystem

In order to control the entire textbook selection system and obtain the textbook order report, the system achieves the above purpose in C/S. It is not released. It is the local client of the textbook committee, where order interface 4 is provided.


Figure 4 order page in the order Subsystem

When the system is started, information about the courses to be opened will be automatically obtained from the Academic Affairs Office database, and will be added to the textbook selection table in the textbook committee database, the corresponding teaching material information is provided and will be added to the Teaching and Research Section teacher's management via B/S. Core code:

Conhome = (connectejbshome) portableremoteobject. Narrow (ref, connectejbshome. Class );
Try
{
Con = conhome. Create ();
If (con. writexk (con. zhuanyi ()))
{
System. Err. Print ("You have transferred the data! ");
}
} Catch (exception ex)
{
Ex. printstacktrace ();
System. Err. Print ("Data Transfer failed! ");
}

It obtains the home interface of the session bean, and writes the course information obtained by the couinfo () method of the Session Bean to the selected textbook table by calling writexk (). Wait for the Teaching and Research Section to select the textbook, then, allocate the original password 888888 to the Teaching and Research Section. Core code:

Try
{
Con = conhome. Create ();
If (con. writetp (con. zhuanyi (), "888888 ")
{
System. Err. Print ("password allocation successful! ");
}
} Catch (exception ex)
{
Ex. printstacktrace ();
System. Err. Print ("password allocation failed! ");
}

After you press the "Refresh order" button, the following list box displays the information of the textbooks to be ordered, including the ISBN number of the title and book and the number of books to be ordered. Implementation Code:

Conhome = (connectejbshome) portableremoteobject. Narrow (ref, connectejbshome. Class );
Try {
Con = conhome. Create ();
If (con. writebaobiao ())
{
System. Err. Print ("Get report data! ");
If (this. getnum ())
{
System. Err. Print ("Get the number of books! ");
}
}
}
Catch (exception ex)
{
Ex. printstacktrace ();
System. Err. Print ("An error occurred while generating the report! ");
}

Writebaobiao () will use a series of functions specifically written in session ejbs to get the number of books to be subscribed, which will not be described here.

6. Textbook Selection System

The textbook selection is an online system. The core part is all made using JSP. It is very convenient to develop JSP with dreamweavre4. The system does not select the Applet as the interface to consider the security needs. The applet needs to run the program on the client. It is actually a type of C/S that can be opened on a webpage, it destroys the advantages of a layer-3 thin client, but can be considered for security-free implementation. The selection page of the system is shown in Figure 5.


Figure 5 selection page of the textbook selection system

There are five JSP pages as the main part of the online textbook selection system. Some JSP pages use the same JavaBean directly, enhancing code reuse. For example, the login page and password modification page use the javaean of pwbean. To make most of the logic implemented in session ejbs, the Java Bean as a part of JSP should be short and refined. Login. jsp is the logon interface. You can automatically obtain the names of all teaching and research sections of the Academic Affairs Office, log on to select. jsp using the password assigned by the teaching board, and select the teaching materials. To select. after JSP, the webpage will automatically obtain the courses that the student is responsible for logging on to the Teaching and Research Section. Here, two text boxes are provided for the instructor to enter the uniform numbers and names of the books he thinks are appropriate, of course, this is uniquely identified by the number. After successful, the successful page success will appear. JSP. Here, you can switch to pwchange. jsp on the password modification page. You need to enter the original logon password and enter the new password twice to change the password. After the modification is successful, a successful page is displayed. The password is in the textbook committee database, which fully reflects the security of JSP.
So far, the core functions have been implemented, and the query and browsing functions of other units have been omitted.

The advantage of using JBuilder to develop a system is that many functions are automatically completed by the system. After completing the preceding steps, you only need to package the project into an ear (Enterprise archive ). In JBuilder, configure tools> enterprise deploy to the server address, port, and user name and password. The system automatically writes the web application deployment information to the deployment description file web. in XML, you only need to right-click the project to publish.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.