Hibernate Configuration Connection Mysql/sqlserver/oracle Database

Source: Internet
Author: User

Hibernate configuration to connect to the database can facilitate our operation of Pojo, saving a lot of time and code. The following is a description of the configuration required to connect different databases in Hibernate.cfg.xml.

Need a database driver package can click here to download: Database jar package: http://pan.baidu.com/s/1jGKEEY6 Password: okq0

1. Hibernate connection to MySQL database

1 <?XML version= ' 1.0 ' encoding= ' UTF-8 '?>2 <!DOCTYPE hibernate-configuration Public3 "-//hibernate/hibernate Configuration DTD 3.0//en"4 "Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">5 <!--Generated by MyEclipse Hibernate Tools.  -6 <hibernate-configuration>7 <session-factory>8     <!--Configuring JDBC Connection Properties -9     < Propertyname= "Myeclipse.connection.profile">Ten Com.mysql.jdbc.Driver One     </ Property> A     < Propertyname= "Connection.url"> - jdbc:mysql://localhost:3306/basehibernate -     </ Property> the     < Propertyname= "Connection.username">Root</ Property> -     < Propertyname= "Connection.password">Sa</ Property> -     < Propertyname= "Connection.driver_class"> - Com.mysql.jdbc.Driver +     </ Property> -     < Propertyname= "dialect"> + Org.hibernate.dialect.MySQLDialect A     </ Property> at  -     <!--Auto-Build table - -     < Propertyname= "Hbm2ddl.auto">Update</ Property> -     <!--automatic submission, no words may appear after Insert database no data - -     < Propertyname= "Connection.autocommit">True</ Property> -  in     <!--Pojo class using hibernate annotation - -     <Mappingclass= "Com.basehibernate.pojo.Department" /> to     <Mappingclass= "Com.basehibernate.pojo.Employee" /> + </session-factory> - </hibernate-configuration>

2. Hibernate connect to Oracle Database

1 <?XML version= ' 1.0 ' encoding= ' UTF-8 '?>2 <!DOCTYPE hibernate-configuration Public3 "-//hibernate/hibernate Configuration DTD 3.0//en"4 "Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">5 <!--Generated by MyEclipse Hibernate Tools.  -6 <hibernate-configuration>7 <session-factory>8     <!--Configuring JDBC Connection Properties -9     < Propertyname= "Connection.driver_class">Ten Oracle.jdbc.driver.OracleDriver One     </ Property> A     < Propertyname= "Connection.url"> - Jdbc:oracle:thin: @localhost: 1521:chanshuyi -     </ Property> the     < Propertyname= "Myeclipse.connection.profile">Oracle</ Property> -     < Propertyname= "Connection.username">Csy</ Property> -     < Propertyname= "Connection.password">Csy</ Property> -     < Propertyname= "dialect">Org.hibernate.dialect.Oracle9Dialect</ Property> +  -     <!--Oracle-specific Commit changes - +     < Propertyname= "Defaultautocommit">True</ Property>  A     <!--Auto-Build table - at     < Propertyname= "Hbm2ddl.auto">Auto</ Property> -     < Propertyname= "Show_sql">True</ Property>   -     <!--automatic submission, no words may appear after Insert database no data - -     < Propertyname= "Connection.autocommit">True</ Property> -      -     <!--Pojo class using hibernate annotation - in     <Mappingclass= "Com.xinpinv.pojo.Product" /> -     <Mappingclass= "Com.xinpinv.pojo.BitInfo" /> to </session-factory> + </hibernate-configuration>

3. Hibernate Connect to Oracle Database

(MARK to write)

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.