java - What mysql driver do I use with spring/hibernate? -


A little confused, 'driverclassname' and 'hibernate.dialect' are both referring to the mysql driver?

What should I use? What connector is that I should use?

  & lt; Bean id = "dataSource" class = "org.apache.commons.dbcp.basicDataSource" delete-method = "off" & gt; & Lt; Property Name = "driverClassName" value = "org.hsqldb.jdbcDriver" /> & Lt; Property name = "url" value = "jdbc: mysql: // localhost / blah" /> & Lt; Property Name = "Hibernate Properties" & gt; & Lt; Price & gt; Hibernate DLuct = Org. Hibernate DIILICT. My SQLDEX is using Iwen, if I can get Maven from the driver who is ideal.  

The app in Context I get the error:

  The class 'org.hsqldb.jdbcDriver' for the connect url can not be made to the JDBC driver  < / P> 

In a bit confused, 'driverclassname' and 'hibernate.dialect' both mention the mysql driver Are you

No, they are not driver class name , driver class name , which is referring to the given JDBC driver Is the class that implements java.sql.Driver . Driver class name is driver specific.

When using MySQL's JDBC driver alias MySQL Connector / J, this class com.mysql.jdbc.Driver as the MySQL connector / j document:

The name of the class implementing java.sql.Driver in MySQL connector / j com. Mysql.jdbc.Driver . (...)

And in fact, they refer to the section Provide instructions to use the driver with your spring .

hibernate.dialect is different, this configuration property is used to define the classname a hibernate org.hibernate.dialect.Dialect < / Code> which is designed to optimize SQL for Hibernate for a specific relational database . Then the Hibernate document is explained in:

(...) Hibernate org.hibernate.dialect.Dialite classname which is to hibernate Allows to generate SQL for a specific relational database.

Example full.classname.of.Dialect

In most cases Hibernate really is the correct org. Hibernate.dialect.Dialect based on the JDBC metadata implementation will be able to choose to get it by the JDBC driver.

5.x for MySQL, if you are using Inodb tables (this would be my recommendation) or org.hibernate.dialect.MySQL5Dialect then < Code> org.hibernate.dialect.MySQL5InnoDBDialect . not you. See the section for a (non-full) list.

The last point, the Maven part, which you did not even mention in your question ... MySQL JDBC Driver Maven is available in central repository and you should use (e.g.). For example, the following question:

allows to find the Maven coordinates of the final version in two clicks:

   & Lt; Version & gt; 5.1.13 & lt; / Edition & gt; & Lt; / Dependencies & gt;  

PS: I do not mean to be harsh and I am happy to help but you are actually trying to take advantage of the documents of those products or structures that you use are doing. What you are asking in this question is well documented (as I have shown) and can be easily found. Learning how to obtain basic information by myself is a fundamental skill for a software developer in my opinion.


Comments