1. Prepare the driverProgram Place the driver in C:/Sun/appserver/domains/domain1/lib/Ext. Note: domain1 is the name of the domain after installation.
2. Create a connection pool Go to the sjsas console:
Http: // localhost: 4848/Username: Admin Password: adminadmin. On the connection pool configuration page, select resources, JDBC, and connection pools. Configuration information: on the right side of the page, select new to enter the configuration page. Enter the connection pool name: MySQL select the data source type: javax. SQL. connectionpooldatasourcedatabase vendor: MySQL. next, enter the following information: databasename: Database Name servername: server name port: Port Number User: User Name password: password to select the information, and then select "add property ". Click "finish.
3. Create a data source On the data source configuration page, select resources, JDBC, and JDBC resources. Select "new" on the interface on the right ".
Enter the JNDI name: MySQL, and select the name of the configured connection pool: MySQL. Click "OK" to complete the configuration.
4. Write a program for testing Main tests
Code As follows:
Context CTX = new initialcontext (); Datasource DS = (datasource) CTX. Lookup ("MySQL "); Connection con = Ds. getconnection (); Note: Import javax. SQL. datasource and javax. Naming .*