Configure the data source in content. xml of Tomcat

Source: Internet
Author: User
I recently developed a secondary development of a college campus card payment system. After getting the source code, I roughly read the code, which is relatively simple and not too complicated. The database is oracle10G, after obtaining the data file, the data is imported smoothly. However, when I was preparing to modify the database configuration file as usual, I found it was written as follows: transactionManagertypeJ

Recently, I was engaged in Secondary Development of a college campus card payment system. After obtaining the source code, I roughly read the code, which is relatively simple and not too complicated. The database is oracle 10 Gb, after obtaining the data file, the data is imported smoothly. However, when I was preparing to modify the database configuration file as usual, I found that:

  1. <TrAnsactionManager type ="JDBC">
  2. < span> "JNDI" > <>
  3. < span> "DataSource" Value = "Java: comp/env/jdbc/nfcDataSource" /> <>

The JNDI method is used to obtain the data source, but the specific configuration of the database is not expectedMcAt content. in the xml file, I found it online and found it was in content. in xml, I read it on the server, and the content. in xml, configuration drops are as follows:

  1. < span> Class = "Html" Name = "Code" > < span> "Jdbc/nfcDataSource" Auth = "Container" <> <>
  2. Type ="Javax. SQL. DataSource"DriverClassName ="Oracle. jdbc. driver. OracleDriver"
  3. Url ="Jdbc: oracle: thin: @ 192.168.0.1: 1521: tt"
  4. Username ="Ttt"Password ="Ttt"MaxActive ="50"MaxIdle ="10"MaxWait ="-1"/>

So far, I have learned how to configure a new data source.

The following is a simple description of java: comp/env found on the Internet:

  1. * ************************* Java: comp/env ***************************
  2. Java: comp/env is the environment naming context (environment naming contExT (ENC )),
  3. It was introduced after EJB specification 1.1 to solve conflicts caused by the original JNDI search and improve the portability of EJB or J2EE applications.
  4. ENC is a reference, which is the logical name used to locate the external resources of an enterprise application. References are defined in the application deployment descriptor file. During deployment, reference the physical location (JNDI name) bound to the resources in the target operable environment ).
  5. ENC is used to free up the hard encoding of the JNDI lookup for other resources. By configuring this reference, you can point the reference to different EJB (JNDI) without modifying the code ).
  6. Commonly used references in J2EE are: --------- JDBC data source reference declaration in java: comp/env/jdbc subcontext --------- JMS connection factory declaration in java: comp/env/jms subcontext

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.