Hibernate不同数据库的链接及方言

<!--MySql 驱动程序 eg. mysql-connector-java-5.0.4-bin.jar-->
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

  <!-- JDBC URL -->
  <property name="connection.url">jdbc:mysql://localhost/dbname?characterEncoding=gb2312</property>

  <!-- 数据库用户名-->
  <property name="connection.username">root</property>

  <!-- 数据库密码-->
  <property name="connection.password">root</property>

  <!--Sql Server 驱动程序 eg. jtds-1.2.jar-->
  <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
  <property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>

  <!-- JDBC URL -->
  <property name="connection.url">jdbc:jtds:sqlserver://localhost:1433;DatabaseName=dbname</property>

  <!-- 数据库用户名-->
  <property name="connection.username">sa</property>

  <!-- 数据库密码-->
  <property name="connection.password"></property>

  <!--Oracle 驱动程序 ojdbc14.jar-->
  <property name="dialect">org.hibernate.dialect.OracleDialect</property>
  <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

  <!-- JDBC URL -->
  <property name="connection.url">jdbc:oracle:thin:@localhost:1521:dbname</property>

  <!-- 数据库用户名-->
  <property name="connection.username">test</property>

  <!-- 数据库密码-->
  <property name="connection.password">test</property>

相关推荐