Tomcat 6.0 + Oracle 10 GB Data source connection test details

Source: Internet
Author: User

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>:

 
 
  1. <Resource name = "jdbc/chong800" // data source name
  2. Auth = "Container"
  3. Type = "javax. SQL. DataSource"
  4. MaxActive = "100"
  5. MaxIdle = "10"
  6. MaxWait = "10000"
  7. Username = "scott" // database username
  8. Password = "tiger" // Database password
  9. DriverClassName = "oracle. jdbc. driver. OracleDriver"
  10. Url = "jdbc: oracle: thin: @ localhost: 1521: chong800"
  11. />

3. Data Source test JSP page

 
 
  1. <% @ Page language = "java" contentType = "text/html; charset = GB18030"
  2. PageEncoding = "GB18030" %>
  3. <% @ Page import = "java. SQL. *" %>
  4. <% @ Page import = "javax. SQL. *" %>
  5. <% @ Page import = "javax. naming. *" %>
  6. <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
  7. <Html>
  8. <Head>
  9. <Meta http-equiv = "Content-Type" content = "text/html; charset = GB18030">
  10. <Title> data source test </title>
  11. </Head>
  12. <Body>
  13. <%
  14. Connection conn = null;
  15. Context context = new InitialContext ();
  16. // Java: comp/env/used only when tomcat is used
  17. DataSource dts = (DataSource) context. lookup ("java: comp/env/jdbc/chong800 ");
  18. Conn = dts. getConnection ();
  19. %>
  20. When conn is null, the data source is not found.
  21. <% = Conn %>
  22. <% Conn. close (); %>
  23. </Body>
  24. </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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.