1. Copy the driver package \ product \ 10.2.0 \ db_1 \ jdbc \ lib under the Oracle directory to copy the ojdbc14.jar file to the lib directory under the tomcat directory;
2. server in the tomcat conf directory. insert the following code in <Context path = "/test" docBase = "D: \ Tools \ Project \ test \ WebRoot" reloadable = "true"> </Context>
- <Resource Name="Jdbc/chong800"// Data source name
- Auth="Container"
- Type="Javax. SQL. DataSource"
- MaxActive="100"
- MaxIdle="10"
- MaxWait="10000"
- Username="Scott"// Database username
- Password="Tiger"// Database Password
- DriverClassName="Oracle. jdbc. driver. OracleDriver"
- Url="Jdbc: oracle: thin: @ localhost: 1521: chong800"
- />
3. Data Source test JSP page
- <% @ PageLanguage="Java" ContentType="Text/html; charset = GB18030"
- PageEncoding="GB18030"%>
- <% @ PageImport="Java. SQL .*"%>
- <% @ PageImport="Javax. SQL .*"%>
- <% @ PageImport="Javax. naming .*"%>
- <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
- <Html>
- <Head>
- <Meta Http-equiv="Content-Type" Content="Text/html; charset = GB18030">
- <Title>Data Source Test</Title>
- </Head>
- <Body>
- <%
- ConnectionConn=Null;
- ContextContext=NewInitialContext ();
- // Java: comp/env/used only when tomcat is used
- DataSourceDts= (DataSource) context. lookup ("java: comp/env/jdbc/chong800 ");
- Conn=Dts. GetConnection ();
- %>
- When conn is null, the data source is not found.
- <% = Conn %>
- <% Conn. close (); %>
- </Body>
- </Html>