5--Hibernate basic Usage--4 5 connection properties for Jndi data sources

Source: Internet
Author: User

Hibernate can use the configuration of the Jndi (Java naming directory Interface,java named directory interface) data source if you do not need hibernate to manage the data source, but rather to access the container management data source directly.

Connect the main configuration properties of the Jndi data source:

⊙hiberante.connection.datasource: Specifies the name of the Jndi data source.

⊙hibernate.jndi.url: Specifies the URL of the Jndi provider, which is optional. You do not need to specify this property if Jndi persisted with hibernate access code in the same app.

⊙hibernate.connection.username: Specifies the user name of the connection database, which is optional.

⊙hibernate.connection.password: Specifies the password for the connection database, which is optional.

Attention:

Even if you use a Jndi data source, you need to specify the dialect in which the database is connected. Although setting up a database dialect is not required, it is necessary to optimize persistent layer access.

XML: Connecting data sources in Tomcat

        <!--Configure Jndi names for Jndi data elements -        < Propertyname= "Connection.datasource">Java:comp/env/jdbc/dstest</ Property>        <!--Configure the dialect of the connected database -        < Propertyname= "dialect">Org.hibernate.dialect.MySQL5InnoDBDialect</ Property>

If the container in which the data source resides supports global transaction management across transactional resources, obtaining a JDBC connection from a Jndi data source automatically participates in container-managed global transactions, not just hibernate local transactions.

La La la

5--Hibernate basic Usage--4 5 connection properties for Jndi data sources

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.