Hibernate 不同数据库的连接及SQL方言

smartleizi 2012-03-27

<!--MySql驱动程序eg.mysql-connector-java-5.0.4-bin.jar-->

<propertyname="dialect">org.hibernate.dialect.MySQLDialect</property>

<propertyname="connection.driver_class">com.mysql.jdbc.Driver</property>

<!--JDBCURL-->

<propertyname="connection.url">jdbc:mysql://localhost/dbname?characterEncoding=gb2312</property>

<!--数据库用户名-->

<propertyname="connection.username">root</property>

<!--数据库密码-->

<propertyname="connection.password">root</property>

<!--SqlServer驱动程序eg.jtds-1.2.jar-->

<propertyname="dialect">org.hibernate.dialect.SQLServerDialect</property>

<propertyname="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>

<!--JDBCURL-->

<propertyname="connection.url">jdbc:jtds:sqlserver://localhost:1433;DatabaseName=dbname</property>

<!--数据库用户名-->

<propertyname="connection.username">sa</property>

<!--数据库密码-->

<propertyname="connection.password"></property>

<!--Oracle驱动程序ojdbc14.jar-->

<propertyname="dialect">org.hibernate.dialect.OracleDialect</property>

<propertyname="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

<!--JDBCURL-->

<propertyname="connection.url">jdbc:oracle:thin:@localhost:1521:dbname</property>

<!--数据库用户名-->

<propertyname="connection.username">test</property>

<!--数据库密码-->

<propertyname="connection.password">test</property>

如果出现如下错误,则可能是HibernateSQL方言(hibernate.dialect)设置不正确。

Causedby:java.sql.SQLException:[Microsoft][SQLServer2000DriverforJDBC][SQLServer]'last_insert_id'不是可以识别的函数名。

RDBMS方言

DB2org.hibernate.dialect.DB2Dialect

DB2AS/400org.hibernate.dialect.DB2400Dialect

DB2OS390org.hibernate.dialect.DB2390Dialect

PostgreSQLorg.hibernate.dialect.PostgreSQLDialect

MySQLorg.hibernate.dialect.MySQLDialect

MySQLwithInnoDBorg.hibernate.dialect.MySQLInnoDBDialect

MySQLwithMyISAMorg.hibernate.dialect.MySQLMyISAMDialect

Oracle(anyversion)org.hibernate.dialect.OracleDialect

Oracle9i/10gorg.hibernate.dialect.Oracle9Dialect

Sybaseorg.hibernate.dialect.SybaseDialect

SybaseAnywhereorg.hibernate.dialect.SybaseAnywhereDialect

MicrosoftSQLServerorg.hibernate.dialect.SQLServerDialect

SAPDBorg.hibernate.dialect.SAPDBDialect

Informixorg.hibernate.dialect.InformixDialect

HypersonicSQLorg.hibernate.dialect.HSQLDialect

Ingresorg.hibernate.dialect.IngresDialect

Progressorg.hibernate.dialect.ProgressDialect

MckoiSQLorg.hibernate.dialect.MckoiDialect

Interbaseorg.hibernate.dialect.InterbaseDialect

Pointbaseorg.hibernate.dialect.PointbaseDialect

FrontBaseorg.hibernate.dialect.FrontbaseDialect

Firebirdorg.hibernate.dialect.FirebirdDialect

相关推荐

LetonLIU / 0评论 2020-05-29
东方咖啡屋 / 0评论 2020-01-06