Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between database drivers and database dialects

What is the difference between database drivers and database dialects?

like image 598
user244634 Avatar asked Jan 18 '10 10:01

user244634


People also ask

What does a database driver do?

A database driver is a computer program that implements a protocol (ODBC or JDBC) for a database connection. The driver works like an adaptor which connects a generic interface to a specific database vendor implementation.

What is the difference between a driver and a connector?

The Connector allows driver vendors to package drivers so that they will be plug-and-play with J2EE applications and enables application server vendors to allow third-party JDBC drivers to be used with their products. What I understand from this is "Driver" is database specific and Connector is independent.

What is database dialect in hibernate?

Dialect is a class that acts as a bridge between Java JDBC types and SQL types, which contains the mapping between java language data type and database datatype. Dialect allows Hibernate to generate SQL optimized for a particular relational database.


1 Answers

This question is not ambiguous , i think it should be answered correctly.

We often use Dialect and Drivers to connect a certain application with a certain database management system.

For example : in grails / java

We define a Dialect property to connect to mysql as having one of this types

MySQL5Dialect, MySQLInnoDBDialect, MySQLMyISAMDialect 

Dialect is an English word that means variant of a language. For example, there are multiple dialects of English. For example, British English and American English.

In the context of databases, people talk about dialects of SQL. SQL is the main language just as English is. Then there are dialects with database specific syntax. For example, Oracle has the rownum keyword.Refe

And , The dialect of the database is simply a term that defines the specific features of the SQL language that are available when accessing that database.

Example of usage in application side  dataSource {     pooled = true     jmxExport = true     driverClassName = "com.mysql.jdbc.Driver"     dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"     username = "root"     password = "root" } 

N.B . Dialect is a mandatory to connect to a database.

Another Hand , DataBase Driver is A program installed on a workstation or server to allow programs on that system to interact with a DBMS.[Refer]

In java we have something called JDBC/ODBC driver specification to connect to a relational Database.

Driver is something like a file or class file written to handle communication between the actual database and to the consuming application (Mysql and java application).

MySQL offers standard database driver connectivity for using MySQL with applications and tools that are compatible with industry standards ODBC and JDBC.After you have the driver file you place it on lib folder and then you need to call or associate it like this.i.e you need to specify URL ,DATABASENAME ,PORT ,PASSWORD .. to connect to the database.

dataSource {       //url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT               =10000;DB_CLOSE_ON_EXIT=FALSE"       databasename = "libdoc"       url = "jdbc:mysql://localhost:3306/"+databasename    } 

Alloha , Happy Learning Day!

like image 81
Daniel Adenew Avatar answered Sep 29 '22 19:09

Daniel Adenew