- Java Hibernate Cookbook
- Yogesh Prajapati Vishal Ranapariya
- 353字
- 2021-07-16 19:59:46
Getting the required libraries for hibernate
To work with hibernate, we need a JAR (Java Archive) file provided by hibernate. Here, we will see how to download the hibernate core distribution. There are multiple ways to get the required libraries; here, we will consider two of them:
- Manually downloading
- Using Maven
Manually downloading
The first and most basic JAR file needed is a JDBC driver. The JDBC driver is a bridge or an API between Java and the database. The JDBC driver provides us with the generic classes that will help us communicate with the database. Generally, the driver is either provided by the database provider or developed by communities; however, you have to get it yourself. This also depends on the type of the database you are using. As we will use the MySQL database for this book, we will use the Mysql-Connector.jar
file.
How to do it…
Let's come back to the library section. Apart from JDBC, you will need the JAR files for hibernate. Perform the following steps:
- Download the hibernate core distribution from http://hibernate.org/orm/.
- Now, place all the files in your classpath if you plan to run a standalone program and put them in the
lib
folder if it's a J2EE project.
Using Maven
If you use the Maven project, it would get rid of your headache of finding all the JAR files for hibernate and the dependent libraries. You can use the following Maven configuration for hibernate.
How to do it…
- Enter the following code into the
pom.xml
source file to show the dependency mapping of hibernate and MySQL inpom.xml
:… <dependencies> <!-- MySQL connector --> <dependency> <groupId>MySQL</groupId> <artifactId>MySQL-connector-Java</artifactId> <version>MySQL-connector-version</version> </dependency> <!-- Hibernate framework --> <dependency> <groupId>hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>hibernate-version</version> </dependency> <dependencies>
Using this method, Maven will download all the required JAR files related to hibernate and the dependent libraries required for hibernate.
- Vue 3移動Web開發(fā)與性能調(diào)優(yōu)實(shí)戰(zhàn)
- OpenStack Cloud Computing Cookbook(Third Edition)
- C程序設(shè)計(jì)簡明教程(第二版)
- 基于差分進(jìn)化的優(yōu)化方法及應(yīng)用
- SSM輕量級框架應(yīng)用實(shí)戰(zhàn)
- 51單片機(jī)C語言開發(fā)教程
- 蘋果的產(chǎn)品設(shè)計(jì)之道:創(chuàng)建優(yōu)秀產(chǎn)品、服務(wù)和用戶體驗(yàn)的七個(gè)原則
- Android移動開發(fā)案例教程:基于Android Studio開發(fā)環(huán)境
- Windows Embedded CE 6.0程序設(shè)計(jì)實(shí)戰(zhàn)
- Vue.js應(yīng)用測試
- Visual FoxPro 6.0程序設(shè)計(jì)
- Building Apple Watch Projects
- Web開發(fā)新體驗(yàn)
- 高性能MVVM框架的設(shè)計(jì)與實(shí)現(xiàn):San
- MonoTouch應(yīng)用開發(fā)實(shí)踐指南:使用C#和.NET開發(fā)iOS應(yīng)用