Tomcat 6.0+Oracle 10 GB Data source connection testThe process is what we will introduce in this article. Next let's take a look at this part of content, hoping to help you.
The connection test procedure is as follows:
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. in xml, 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
- <% @ Page language = "java" contentType = "text/html; charset = GB18030"
- PageEncoding = "GB18030" %>
- <% @ Page import = "java. SQL. *" %>
- <% @ Page import = "javax. SQL. *" %>
- <% @ Page import = "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>
- <%
- Connection conn = null;
- Context context = new InitialContext ();
- // Java: comp/env/used only when tomcat is used
- DataSource dts = (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>
The above is the connection test process and implementation code of Tomcat 6.0 + Oracle 10g data source. We will introduce it here. I hope this introduction will help you gain some benefits!