hibernate.cfg.xml文件连接mySql、Oracle、SqlServer配置
1.连接mySql,文件配置如下:
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhibernate-configurationPUBLIC
"-//Hibernate/HibernateConfigurationDTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<propertyname="connection.username">root</property>
<propertyname="connection.password">253503125</property>
<propertyname="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<propertyname="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<propertyname="show_sql">true</property>
</session-factory>
</hibernate-configuration>
2.连接Oracle,文件配置如下:
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhibernate-configurationPUBLIC
"-//Hibernate/HibernateConfigurationDTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="connection.url">jdbc:oracle:thin:@192.168.7.248:1521:orcl</property>
<propertyname="connection.username">liferay</property>
<propertyname="connection.password">liferay</property>
<propertyname="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<propertyname="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<propertyname="show_sql">true</property>
</session-factory>
</hibernate-configuration>
3.连接sqlServer,问津配置如下:
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhibernate-configurationPUBLIC
"-//Hibernate/HibernateConfigurationDTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="connection.url">jdbc:sqlserver://192.168.7.199:1433;databaseName=xycms</property>
<propertyname="connection.username">sa</property>
<propertyname="connection.password">123456</property>
<propertyname="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<propertyname="dialect">org.hibernate.dialect.SQLServerDialect</property>
<propertyname="show_sql">true</property>
</session-factory>
</hibernate-configuration>