Configuring MyBatis 3 With MySQL In Java Projects

What is MyBatis?

MyBatis is a Higher version of iBatis. Its lightweight persistence framework which is mapping SQL databases and objects in Java, .NET, and Ruby on Rails.

MyBatis support for custom SQL, Views, advanced mappings, stored procedures and declarative data caching.It is the new version of the iBatis Data Mapper Java Framework, which allows you to use a relational database with object-oriented applications.

In single line, we can describe MyBatis as a SQL Mapping Framework for Java, .NET and Ruby on Rails.

MyBatis Design Aspects:

MyBatis comes with the following design aspects:

Why MyBatis?

As we all are familier with today’s market conditions.A lot of freamworks are available for Database Mapping Architecrture like Hibernet then surely one question must comes into mind why we use MyBatis?
If we observe following few suitiations then we got the answer.
Suppose if

then positively MyBatis is a better solution.

Also If you are using stored procedures, well you can do it in Hibernate but it is little difficult in comparision of MyBatis. As an alternative solution MyBatis maps results sets to objects, so no need to care about table structures.

Prepare a Database for sample example:

Let’s get started:

To see how Tomcat, MyBatis and MySQL work together we’re going to create a small java application in Eclipse called “MyBatisDemo”.You can download the Sample Project Here.

Technical pros of MyBatis:

Here are few pros of using MyBatis:

Summary of MyBatis:

MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results.It is a easiest way to build better database oriented application more quickly, efficiently with less code.

References for Blog:

1. http://www.mybatis.org/core/

Download the Sample Project:Here

Exit mobile version