Oracle Data Source Settings in WebSphere ------ JSP and Oracle Database

zhaozj2021-02-16  54

Oracle Data Source Settings in WebSphere

------ JSP and Oracle Database Connections

Oracle is currently the most popular relational object database in the world, has become the preferred database product of large and medium-sized management information systems; and the Java language is born with the platform, plus "one writing, run" and safety protection, so JAVA language-based JSP de-late backend application developers love. Undebbly JSP and Oracle's perfect combination provide our best choice for our development server-side database applications.

Sun provides four types of drivers for JSP connection database, and we often encounter all kinds of problems in JSP connection Oracle. Here, I will introduce the setting problem of the data source in the Pure Java JDBC DRIVER type.

Before the setting of the Oracle data source, you must load the Oracle driver into the ClassPath directory, which will be loaded in the application: Class.Forname ("Oracle.jdbc.driver.Oracledriver")

When performing an Oracle driver to load into a ClassPath directory, there are several ways:

1. Add a driver package (Classes111.zip) to the ClassPath variable

2. Copy the driver (such as Classes111.zip) to the / jre / lib / ext directory, and renamed * .jar. (If there is no name, no effect)

--- WebSphere is D: / WebSphere / AppserVer / Java / JRE / LIB / EXT

3. Copy the Oracle directory after extracting classes111.zip to the class directory

Note: Do not load both drive classes (CLASS111.ZIP and Classes12.zip)

To operate the database, you must obtain a list of connection objects. JDBC drivers to join the Oracle database to connect to the Oracle database.

1. JDBC OCI: Connection Conn = DriverManager.getConnection ("JDBC: Oracle: OCI8: @ ", user, password);

2. JDBC Thin: Connection Conn = DriverManager.getConnection ("JDBC: Oracle: Thin: @ip: port: ", user, password);

3. JDBC KPRB: Connection Conn = DriverManager.getConnection ("JDBC: Oracle: Kprb:")

The JDBC OCI primary user local database connection, while JDBC Kprb is used for server-side database connections (such as: stored procedures), Database, User, Password for the corresponding database SID, username and password

Note: Oracle is trying to replace the SID positioning database through a new service channel, which has been implemented since Oracle 8.1.7. Therefore, it obtains the listed method:

JDBC: Oracle: Thin: [ / ] @ // [: ] / Statement object is used to send SQL statements into the database, and ResultSet is used to obtain the database Result set:

Statement Stmt = conn.createstatement ();

ResultSet RS = Stmt.executeQuery (SQL);

In the class provided by the JDBC, the support of classes102.zip users JDK1.0.2, classs111.zip is used for JDK1.1.1 support and classs12.zip is used for JDK1.2 support, but classes102.zip and classes12.zip can also support JDK1.3 is not in Oracle9.02 to introduce new Ojdbc1.4.jar for JDK1.4.

Program Description: Set the database name, username, user password, IP by reference to JavaBean in the application. After adjusting ExcuteUpdate () to update the database, ExcuteQuery () to query the database.

Reference book:

1. "JSP application development details" electronic industry publisher

2. Oracle8.1.5 and Oracle9.0.2 JDBC Description Documentation

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

New Post(0)