Content introduction Steven Gould introduces 13 core technologies for Java2 Platform Enterprise (J2EE) in the text: JDBC, JNDI, EJBS, RMI, JSP, Java Servlets, XML, JMS, Java IDL, JTS, JTA, JavaMail, and Jaf. To contact reality, Gould introduces these technologies from a widely applying product environment of BEA Systems based on the WebLogic application server.
Java was originally debuted in the browser and client machine. At that time, many people question whether it is suitable for the development of the server. Now, with the increase of third parties supporting the Java2 Platform Enterprise (J2EE), Java is widely accepted as one of the preferred platforms for the development of enterprise-level server-side solutions. The J2EE platform consists of a set of services, Application Interface (APIs), and protocols that provide functional support for developing web-based multi-layer applications. In this article I will explain 13 core technologies for J2EE: JDBC, JNDI, EJBS, RMI, JSP, Java Servlets, XML, JMS, Java IDL, JTS, JTA, JavaMail, and Jaf, while will also describe when Where to use these technologies. Of course, I have to introduce how to interact between different technologies. In addition, in order to better feel the real application of J2EE, I will introduce these technologies in a WebLogic application server, a widely applying product environment from the BEA Systems. Regardless of the WEBLOGIC app server and J2EE's newcomer, it is also believed that this article must have a reference value in this article. Macro Impression: Distributed Structure and J2EE past, two-layer application - commonly referred to as Client / Server applications - is the most talkative. In many cases, the only service provided by the server is the database service. In this solution, the client program is responsible for data access, implementing business logic, displaying results with appropriate style, popping up the preset user interface, accept user input, etc. The Client / Server structure is usually relatively easy when deploying, but it is difficult to upgrade or improve, and often based on some proprietary protocol, usually a certain database protocol. It makes it difficult to reuse business logic and interface logic. More importantly, in the web era, the second-floor apps usually cannot reflect good scalability, so it is difficult to adapt to the requirements of the Internet. The part of the SUN design J2EE is to solve the defects of the secondary structure. Thus, J2EE defines a set of standards to simplify the development of N-layer enterprise applications. It defines a standardized component and provides a complete service for these components. J2EE also automatically handles many implementation details, such as security, multithreading, etc. for applications. Developing N-layer applications with J2EE includes cutting different levels in the secondary structure into many layers. A N-layer application A can provide a separate layer for each of the following services: Display: In a typical web application, the browser running on the client machine is responsible for implementing the user interface. Dynamically generated display: Although the browser can complete some dynamic content display, these dynamic generated work should be made in the web server side, using JSP, Servlets, or XML (Scalable Markup Language) and Scalable style sheet language). Business logic: Business logic is suitable for implementation with Session EJBS (later will be described later). Data Access: Data Access is implemented with Entity EJBS (later later) and JDBC. Background System Integration: Integration of the same system may need to use many different techniques, as is the best need to be determined according to the characteristics of the background system. You may start surprising: Why have so many layers? In fact, multi-level approach enables enterprise-class applications with strong scalability, which allows each layer to focus on specific roles. For example, let the web server provide pages, apply the server to process the application logic, and the database server provides database services. Since J2EE is based on the Java2 Platform Standard (J2SE), all of the advantages and functions of J2SE are available.
Including "Write once, you can use" portability, access to the database through the JDBC, CORBA technology interacting with the original enterprise resources, and a validated security model. On this basis, J2EE adds support for EJB (Enterprise Java Components), Java Servlets, Java Server Page (JSPS), and XML technology. Distributed Structure and WebLogic Application Server J2EE provides a framework - a set of standard APIs for developing distributed structures, the actual implementation of this framework is left to third-party manufacturers. Some manufacturers are only focusing on specific components in the J2EE architecture, such as Apache's Tomcat provides support for JSP and Servlets, and BEA system companies provide a more complete implementation of the entire J2EE specification through its WebLogic application server products. The process of distributed and deploying distributed applications with better scalability is greatly simplified. WebLogic and J2EE have handled a lot of regular programming tasks, including providing transaction services, security areas, reliable messages, names, and directory services, database access, and connect pools, thread pools, load balancing, and fault tolerance. By providing these public services in a standard, ease of use, an application system with better scalability and maintainability is created, which provides a large number of users with increased availability. J2EE Technology In the next section, we will describe a variety of techniques that make up J2EE and how the WebLogic server is supported in a distributed application. The most commonly used J2EE technology should be JDBC, JNDI, EJB, JSP, and servlets, which we will make more careful investment. Java Database Connectivity (JDBC) JDBC API accesss a wide variety of databases in a unified manner. Like ODBC, JDBC hides the different characteristics of different databases for developers. In addition, since JDBC is based on Java, the platform independence of data inventory is also provided. JDBC defines four different drivers. The JDBC-ODBC Bridge is clearly very practical, and the JDBC-ODBC Bridge is clearly very practical, developers can use through the JDBC-ODBC bridge, developers can use JDBC to access the ODBC data source. Insufficient, he needs to install an ODBC driver on the client, in other words, a version of Microsoft Windows must be installed. Using this type You need to sacrifice the platform independence of JDBC. In addition, the ODBC driver also needs to have a client control permission. Type 2: JDBC-Native Driver Bridge JDBC Local Driver Bridge provides a JDBC interface, which is built on top of the local database driver without the need to use ODBC. The JDBC driver converts the API of the database from the standard JDBC call to local calls. With this type, you need to sacrifice the platform independence of JDBC, and also require some local code on the client. Type 3: JDBC-Network Bridge JDBC network bridge driver no longer needs a client database driver. It uses an intermediate server on the network to access the database. This application makes it possible to achieve the implementation of the technique, including load balancing, connection buffer pool and data cache. Since the third type is often only a relatively less download time, there is a platform independence, and it is not necessary to install and acquire control over the client, so it is well suited for the application on the Internet. Type 4: Pure Java Driver Quick 4 types Direct access to the database by using a pure Java database driver. This type actually implements a 2 layer structure on the client. To apply in the N-layer structure, a better approach is to write an EJB that allows it to include access code and provide a service that has database independent to the client.
The WebLogic server provides a JDBC driver for some of the usual databases, including Oracle, Sybase, Microsoft SQL Server, and Informix. It also has a JDBC driver for Cloudscape, which is a pure Java's DBMS. The WebLogic server has an assessment version of the database. Let's take an example. JDBC instance In this example we assume that you have created a PhoneBook database in Cloudscape and contain a table named Contact_Table, which has 2 fields: Name and Phone. The Cloudscape JDBC Driver is first loaded, and Driver Manager is requested to get a connection to the PhoneBook Cloudscape database. With this connection, we can construct a Statement object and use it to perform a simple SQL query. Finally, use the loop to traverse all the data of the result set, and output the contents of the Name and the Phone field with standard output. Import java.sql. *;
Public Class JDBCEXAMPLE
{
Public static void main (string args [])
{
Try
{
Class.Forname ("com.cloudscape.core.jdbcdriver");
Connection conn = drivermanager.getConnection ("JDBC: Cloudscape: Phonebook);
Statement Stmt = conn.createstatement ();
String SQL = "SELECT NAME, Phone from Contact_Table Order By Name";
ResultSet ResultSet = Stmt.executeQuery (SQL);
String name;
String phone;
While (resultSet.next ())
{
Name = resultSet.getstring (1) .trim ();
Phone = ResultSet.getstring (2) .trim ();
System.out.println (Name "," Phone);
}
}
Catch (Exception E)
{
// Handle Exception Here
E.PrintStackTrace ();
}
}
}
OK. Then let's take a look at how JDBC is used in business applications. JDBC's application above in enterprise applications is actually very basic, and some may be slightly negligible. It assumes a 2-layer structure. In a multi-layer enterprise application, larger may communicate on the client and an EJB, which will establish a database connection. To achieve and improve scalability and system performance, the WebLogic server provides support for connecting buffer CONNECTION POLEL. The Connection Pool reduces the consumption of establishing and releasing database connections. Such buffer pools can be established after the system is started, and thereafter, there is a request for the database, and the WebLogic server can take the data from the buffer pool. The data buffer pool can be defined in the WebLogic.Properties file of the WebLogic server. (Refer to the example in the WebLogic.properties file, more detailed reference information in the WebLogic server document) Another common database feature in an enterprise-level application is transaction processing. The transaction is a set of statements that must be processed as the same statement to ensure data integrity. By default, JDBC uses Auto-Commit transaction mode. This can be implemented by using the setAutocommit () method of the CONNECTION class. Now we have had some understanding of JDBC, which turns to JNDI.