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