1 summarizes the steps the University of use JDBC programming (basic already forgotten)
Load the database driver
Creating and database connection
Create a jdbc statement objects
Set sql statement
PreparedStatement set parameters using sql statement
By statement object to execute sql statement returning the result
The results of the implementation of sql parsing process
The release of resources (resultSet, preparedstatement, connection)
2, some of the problems of JDBC
Frequently create, release the database connection
sql statement is hard-coded in the code, java
Hard-coded parsing results
3、mybatis
The greatest advantage is the java code sql statement isolate, so that we can concentrate on writing sql
SqlMapConfig.xml is mybatis core configuration files, configuration file contents as a data source, transaction management
Mapper.xml sql file that is mapped files, configure the operation of the database sql statement (This file needs SqlMapConfig.xml loaded)
SqlSessionFactory i.e. configuration information configured by the session factory environment mybatis
SqlSession created by a session that is factory session, the database needs to be operating by sqlSession
mybatis underlying actuator Executor customized database interface operation, there are two interfaces implemented Executor, it is a basic actuator, an actuator is a buffer
MappedStatement mybatis is a bottom package object that wraps mybatis configuration information and mapping information sql
Mapper.xml a file corresponding to a sql MappedStatement objects, sql id of the id that is MappedStatement
Sql MappedStatement performed on the input parameters are defined, including the HashMap, basic types, pojo, Executor mapped to sql by java object before performing sql MappedStatement input, the input parameter mapping is provided jdbc programming parameters preparedStatement
MappedStatement sql execution of the output is defined, comprising the HashMap, basic types, pojo, Executor by mapping MappedStatement output after execution result to sql java object, the output of the mapping process is equivalent to the analysis process jdbc programming process results