First, the method of WebLogic page and data communication, the general use of Java control directly access to the data connection pool, the direct operation of the data are defined in the Java Control, page flow as a logical processing unit of data, the normal page as a display layer. You can see WebLogic This method is a typical three-layer structure, data layer (Java control), Business Logic Layer (page flow), Display layer (page)
Second, establish connection pool, data source
Configure the Config.xml file, which is weblogic with the E:\bea\weblogic81\samples\domains\workshop
of Cgserver.
<jdbcconnectionpool drivername= "Oracle.jdbc.driver.OracleDriver"
logindelayseconds= "1" maxcapacity= "name=" Liwei "
Passwordencrypted= "{3des}wbnjpyuoave=" properties= "User=liwei"
targets= "Cgserver" url= "Jdbc:oracle:thin: @localhost: 1521:wincn"/>
<jdbctxdatasource jndiname= "Liwei" name= "Liwei" poolname= "Liwei" targets= "Cgserver"/>
or tool->weblogic server-> Data source Viewer-> New data source step is relatively simple, the main input corresponding parameters:
Drivername= "Oracle.jdbc.driver.OracleDriver"
Url= "Jdbc:oracle:thin: @localhost: 1521:WINCN"
Then the username password can be.
The above content can refer to "WebLogic JSP connection Database" article
Third, related pages
Test\testweb\recordset\recordsetcontroller.jpf
test\testweb\recordset\index.jsp
TEST\TESTWEB\RECORDSET\TEST.JCX Java controls
IV. Database
CREATE TABLE TEST (
A VARCHAR2 (10),
B VARCHAR2 (10),
C VARCHAR2 (10),
D VARCHAR2 (10)
)
Five, data layer (Java control)
This example uses the Tbltest custom static class implementation to return the DataSet. (You can also use the Netui:gird+recordset implementation, see the sample yourself)
The Update method is very similar to the Insert method, so no specific implementation code is provided.
There is nothing complicated about the data layer, but it provides enough data manipulation interfaces for the logical layer (page flow). Tbltest a custom static class is an essential part of completing data transfer.
TEST\TESTWEB\RECORDSET\TEST.JCX Full Code
Package recordset;
Import com.bea.control.*;
Import java.sql.SQLException;
/*
* @jc: Connection data-source-jndi-name= "Liwei"
*/
Public interface test extends Databasecontrol, com.bea.control.ControlExtension
{
/**
* @jc: SQL statement::
* INSERT into TEST (a,b,c,d)
* VALUES ({_a},{_b},{_c},{_d})
* ::
*/
public int Insert (string _a, String _b,string _c,string _d);
/**
* @jc: SQL statement::
* UPDATE TEST SET B = {_b}, C = {_c}, D = {_d} WHERE A = {_a}
* ::
*/
public int Update (string _a, String _b,string _c,string _d);
/**
* @jc: SQL statement::
* DELETE TEST WHERE A = {_a}
* ::
*/
public int Delete (String _a);
/**
* @jc: SQL statement::
* SELECT * from TEST WHERE A = {_a}
* ::
*/
Public tbltest Select (String _a);
/**
* @jc: SQL statement::
* SELECT * FROM TEST
* ::
*/
Public tbltest[] SelectAll ();
public static class Tbltest implements Java.io.Serializable
{
Public String A;
Public String B;
Public String C;
Public String D;
}
}