Get the App
SLTechnology News&Howtos  ›  Development  › 

The connection of different databases in Hibernate and what is the dialect of SQL?

Shulou Source: shulou.com Published: 2022-06-02 08:59:11 10月04日 Update

What this article shares to you is about the connection of different Hibernate databases and what the SQL dialect is like. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

The following code shows the connections between different databases in 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>

If the following error occurs, it may be that the Hibernate SQL dialect (hibernate.dialect) setting is incorrect.

Caused by: java.sql.SQLException: [Microsoft] [SQLServer 2000 Driver for JDBC] [SQLServer] 'last_insert_id' is not a recognized function name.

RDBMS dialect DB2org.hibernate.dialect.DB2DialectDB2 AS/400org.hibernate.dialect.DB2400DialectDB2 OS390org.hibernate.dialect.DB2390DialectPostgreSQLorg.hibernate.dialect.PostgreSQLDialectMySQLorg.hibernate.dialect.MySQLDialectMySQL with InnoDBorg.hibernate.dialect.MySQLInnoDBDialectMySQL with MyISAMorg.hibernate.dialect.MySQLMyISAMDialectOracle (any version) org.hibernate.dialect.OracleDialectOracle 9i/10gorg.hibernate.dialect.Oracle9DialectSybaseorg.hibernate.dialect.SybaseDialectSybase Anywhereorg.hibernate.dialect.SybaseAnywhereDialectMicrosoft SQL Serverorg.hibernate.dialect.SQLServerDialectSAP DBorg.hibernate.dialect.SAPDBDialectInformixorg.hibernate.dialect.InformixDialectHypersonicSQLorg.hibernate.dialect.HSQLDialectIngresorg.hibernate.dialect.IngresDialectProgressorg .hibernate.dialect.ProgressDialectMckoi SQLorg.hibernate.dialect.MckoiDialectInterbaseorg.hibernate.dialect.InterbaseDialectPointbaseorg.hibernate.dialect.PointbaseDialectFrontBaseorg.hibernate.dialect.FrontbaseDialectFirebirdorg.hibernate.dialect.FirebirdDialect above is the connection of Hibernate different databases and what the SQL dialect is like. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Dialects differences data databases more knowledge articles utility code functions that is work meetings articles look knowledge points industry details information channels follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple Shulou Technology OPPO Reno Shulou Information