1, configure the connection pool through the Http://localhost:7001/console into the management console
In the left-hand menu, enter mydomain (the custom domain name)-Service-jdbc-connection buffer pool
Click "Configure the new JDBC Connection Pool ... ”
Data type selection: Oracle
DatabaseDriver selection: Oracle ' s Driver (Thin) version:9.0.1,0.2.0,10
Click "Continue" in the lower right corner
Write the connection pool name you want to set in the name (in this case: Myconnection1)
Database name: The name of the database to access
Host Name: Host name or IP address written to the database server (in this case: 192.168.1.251)
The port number defaults to: 1521
Database user name, password fill in according to the specific situation
Click "Continue"
Click "Test driver Configuration" on the next page to show "Successful Connection"
Click "Create and Deploy"
Myconnection1 configuration items appear in the list of new pages
Connection Pool Configuration Complete
2. Test Configuration Connection Pool
In the left-hand menu, enter mydomain (the custom domain name)-Service-jdbc-connection buffer pool
Click "Myconnection1"
Click the "Connect" tab in the config page check
Click the Advanced option "show"
Select test reserved connection, test create connection, test release connection
Write the name of a random table in the database in test table name
Write "SQL SELECT * from student" in "Initial SQL"
Select the Support local transaction option
Click "Apply"
On the test page, click the test buffer pool.
Show "Test Success"
3. Configure JDBC Data source
Enter mydomain (custom domain name) in the menu on the left side of the admin console-service-jdbc-data source
Click on "Configure New JDBC Data Source"
Write the name of the data source you want to configure (in this example: Mydatasource1)
Write the name of the access in the Jndi name (in this case: TEST/ORA9)
Click "Continue"
Select Myconnection1 in the buffer pool name
Click "Continue", "create"
Mydatasource1 configuration items appear in the list
Data Source Configuration Complete
4. Test JDBC Data source
Create and deploy testjdbc.jsp, the source code is as follows:
<%@ page import= "java.sql.*"%>
<%@ page import= "javax.naming.*"%>
<%@ page import= "javax.sql.*"%>
<%
try{
Context Initctx=new InitialContext ();
DataSource ds= (DataSource) initctx.lookup ("Test/student");
Connection conn=ds.getconnection ();
Statement stmt=conn.createstatement ();
Query table EMP Data bar count
ResultSet rs=stmt.executequery ("SELECT count (*) as num from emp");
Rs.next ();
Out.println (rs.getstring ("num"));
Rs.close ();
Stmt.close ();
}catch (Exception e) {
E.printstacktrace ();
}
%>
Change "test/student" to its own Jndi name
Convert EMP to table in database
Run after deployment